[16.0] add purchase_report_received_amount

This commit is contained in:
Luis 2026-03-09 17:09:55 +01:00
parent bf02699b61
commit d9a0eeb878
7 changed files with 193 additions and 0 deletions

View file

@ -0,0 +1 @@
from . import purchase_report

View 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