diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 4e9957c319f..e667d36a59d 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -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 ''' diff --git a/addons/account/tests/test_account_invoice_report.py b/addons/account/tests/test_account_invoice_report.py index 92009dd8522..1a4526cd038 100644 --- a/addons/account/tests/test_account_invoice_report.py +++ b/addons/account/tests/test_account_invoice_report.py @@ -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], ])