[FIX] account: fix Average Price measure
Open Accounting>Reporting>Invoices Add measure 'Average Price' The reported amount will be wrong, as it will not consider the quantity, making an average of the price subtotal opw-2522621 closes odoo/odoo#71862 X-original-commit: 978012b38abb941c88fe85f1befa2ac659545915 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
@@ -98,7 +98,11 @@ class AccountInvoiceReport(models.Model):
|
||||
line.quantity / NULLIF(COALESCE(uom_line.factor, 1) / COALESCE(uom_template.factor, 1), 0.0) * (CASE WHEN move.move_type IN ('in_invoice','out_refund','in_receipt') THEN -1 ELSE 1 END)
|
||||
AS quantity,
|
||||
-line.balance * currency_table.rate AS price_subtotal,
|
||||
-line.balance / NULLIF(COALESCE(uom_line.factor, 1) / COALESCE(uom_template.factor, 1), 0.0) * currency_table.rate
|
||||
-COALESCE(line.balance
|
||||
/ NULLIF(line.quantity, 0.0)
|
||||
/ NULLIF(COALESCE(uom_line.factor, 1), 0.0)
|
||||
/ NULLIF(COALESCE(uom_template.factor, 1), 0.0),
|
||||
0.0) * currency_table.rate
|
||||
AS price_average,
|
||||
COALESCE(partner.country_id, commercial_partner.country_id) AS country_id
|
||||
'''
|
||||
|
||||
@@ -21,7 +21,7 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon):
|
||||
(0, None, {
|
||||
'product_id': cls.product_a.id,
|
||||
'quantity': 3,
|
||||
'price_unit': 1000,
|
||||
'price_unit': 750,
|
||||
}),
|
||||
(0, None, {
|
||||
'product_id': cls.product_a.id,
|
||||
@@ -108,11 +108,11 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon):
|
||||
def test_invoice_report_multiple_types(self):
|
||||
self.assertInvoiceReportValues([
|
||||
#price_average price_subtotal quantity
|
||||
[2000, 2000, 1],
|
||||
[1000, 1000, 1],
|
||||
[1000, 1000, 3],
|
||||
[6, 6, 1],
|
||||
[-20, -20, -1],
|
||||
[-20, -20, -1],
|
||||
[-600, -600, -1],
|
||||
[2000, 2000, 1],
|
||||
[1000, 1000, 1],
|
||||
[250, 750, 3],
|
||||
[6, 6, 1],
|
||||
[-20, -20, -1],
|
||||
[-20, -20, -1],
|
||||
[-600, -600, -1],
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user