[FIX] account : Average price fix invoice report
Current behavior: Invoices report had a wrong average price when invoice had credit note Steps to reproduce: Create a db with accounting Create a customer C and a Product P Create an Invoice for C for 10 pieces of P Create a Credit note for C for 1 P Go to Reporting > Invoice Analysis Open the pivot view, in the Measures, display the Average Price, the Product quantity and the Untaxed Total The Total multiplied by the quantity is not equals to the average. opw-2557420 closes odoo/odoo#81238 X-original-commit: ef26467e288a12571c37d4c133b44f08d99cc702 Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
@@ -100,7 +100,7 @@ class AccountInvoiceReport(models.Model):
|
||||
-line.balance * currency_table.rate AS price_subtotal,
|
||||
-COALESCE(
|
||||
-- Average line price
|
||||
(line.balance / NULLIF(line.quantity, 0.0))
|
||||
(line.balance / NULLIF(line.quantity, 0.0)) * (CASE WHEN move.move_type IN ('in_invoice','out_refund','in_receipt') THEN -1 ELSE 1 END)
|
||||
-- convert to template uom
|
||||
* (NULLIF(COALESCE(uom_line.factor, 1), 0.0) / NULLIF(COALESCE(uom_template.factor, 1), 0.0)),
|
||||
0.0) * currency_table.rate AS price_average,
|
||||
|
||||
@@ -103,6 +103,7 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon):
|
||||
'price_subtotal': vals[1],
|
||||
'quantity': vals[2],
|
||||
} for vals in expected_values_list]
|
||||
|
||||
self.assertRecordValues(reports, expected_values_dict)
|
||||
|
||||
def test_invoice_report_multiple_types(self):
|
||||
@@ -112,7 +113,7 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon):
|
||||
[1000, 1000, 1],
|
||||
[250, 750, 3],
|
||||
[6, 6, 1],
|
||||
[-20, -20, -1],
|
||||
[-20, -20, -1],
|
||||
[-600, -600, -1],
|
||||
[20, -20, -1],
|
||||
[20, -20, -1],
|
||||
[600, -600, -1],
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user