From bef0da3a7aff74fecce7b418164257ad0cd37c4d Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 26 Nov 2015 11:55:00 +0100 Subject: [PATCH] [FIX] account: Total Receivable and Payable The fields Total Receivable and Payable are calculated as debit-credit. However, this leads to a wrong computation if, for example, a payment is used to pay several invoices. For example: - Create a customer invoice of 2500 USD - Register a payment of 3000 USD The Total Receivable will be 3000 USD instead of 500 USD. At the same time, this commits changes the sign of the field. The help depicts the Total Receivable field as "Total amount this customer owes you". Therefore, one would expect that if the customer owes 250 USD, the Total Receivable is 250 USD, not -250 USD. The same logic applies to Total Payable. opw-657053 --- addons/account/models/partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index 39cf7a0a17f..f681c48ed0e 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -232,7 +232,7 @@ class ResPartner(models.Model): def _credit_debit_get(self): tables, where_clause, where_params = self.env['account.move.line']._query_get() where_params = [tuple(self.ids)] + where_params - self._cr.execute("""SELECT l.partner_id, act.type, SUM(l.debit-l.credit) + self._cr.execute("""SELECT l.partner_id, act.type, SUM(l.amount_residual) FROM account_move_line l LEFT JOIN account_account a ON (l.account_id=a.id) LEFT JOIN account_account_type act ON (a.user_type_id=act.id)