[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
This commit is contained in:
Nicolas Martinelli
2015-11-26 12:19:41 +01:00
parent 5b82c9ccb4
commit bef0da3a7a
+1 -1
View File
@@ -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)