[16.0] add purchase_report_received_amount
This commit is contained in:
parent
bf02699b61
commit
d9a0eeb878
7 changed files with 193 additions and 0 deletions
1
purchase_report_received_amount/report/__init__.py
Normal file
1
purchase_report_received_amount/report/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import purchase_report
|
||||
37
purchase_report_received_amount/report/purchase_report.py
Normal file
37
purchase_report_received_amount/report/purchase_report.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# Copyright 2024 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class PurchaseReport(models.Model):
|
||||
_inherit = "purchase.report"
|
||||
|
||||
price_received = fields.Float(
|
||||
string="Received Amount",
|
||||
readonly=True,
|
||||
help="Amount of received quantity (with discount applied)",
|
||||
)
|
||||
price_received_undiscounted = fields.Float(
|
||||
string="Received Amount (Undiscounted)",
|
||||
readonly=True,
|
||||
help="Amount of received quantity without discount",
|
||||
)
|
||||
|
||||
def _select(self):
|
||||
res = super()._select()
|
||||
# Add received amount with discount (uses the already discounted price from purchase_discount)
|
||||
res += """,
|
||||
sum(
|
||||
l.qty_received / line_uom.factor * product_uom.factor
|
||||
* (1.0 - COALESCE(l.discount, 0.0) / 100.0) * l.price_unit
|
||||
/ COALESCE(po.currency_rate, 1.0)
|
||||
)::decimal(16,2) * currency_table.rate as price_received"""
|
||||
# Add received amount without discount
|
||||
res += """,
|
||||
sum(
|
||||
l.qty_received / line_uom.factor * product_uom.factor
|
||||
* l.price_unit
|
||||
/ COALESCE(po.currency_rate, 1.0)
|
||||
)::decimal(16,2) * currency_table.rate as price_received_undiscounted"""
|
||||
return res
|
||||
Loading…
Add table
Add a link
Reference in a new issue