diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index aa37b7bec3cf3..7861644525ac4 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -114,7 +114,8 @@ def _sub_select(self): ai.partner_bank_id, SUM ((invoice_type.sign_qty * ail.quantity) / u.factor * u2.factor) AS product_qty, SUM(ail.price_subtotal_signed * invoice_type.sign) AS price_total, - SUM(ai.amount_total * invoice_type.sign) AS amount_total, + (ai.amount_total * invoice_type.sign) / (SELECT count(*) FROM account_invoice_line l where invoice_id = ai.id) * + count(*) * invoice_type.sign AS amount_total, SUM(ABS(ail.price_subtotal_signed)) / CASE WHEN SUM(ail.quantity / u.factor * u2.factor) <> 0::numeric THEN SUM(ail.quantity / u.factor * u2.factor)