From 5a8e35dc7a96488f671deac7650d34994f72cc0d Mon Sep 17 00:00:00 2001 From: Olivier Colson Date: Fri, 18 Jan 2019 14:18:31 +0000 Subject: [PATCH] [FIX] account: properly manage multi currencies in invoices' outstanding payments Before that, having a payment with amount_residual=0, but amount_residual_currency!=0 did not display it. Also, 'outstanding credits/debits' label was displayed in case amount_residual was != 0 with an amount_currency=0 (and of course, a currency_id value was set on the aml). This could for example happen in case of partial reconciliation, were the amount_residual field is used to keep track of what will have to be written in the exchange rate difference entry when the reconciliation becomes full. closes odoo/odoo#30362 --- addons/account/models/account_invoice.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 008c52777ad..781dd33451f 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -111,7 +111,12 @@ class AccountInvoice(models.Model): def _get_outstanding_info_JSON(self): self.outstanding_credits_debits_widget = json.dumps(False) if self.state == 'open': - domain = [('account_id', '=', self.account_id.id), ('partner_id', '=', self.env['res.partner']._find_accounting_partner(self.partner_id).id), ('reconciled', '=', False), ('amount_residual', '!=', 0.0)] + domain = [('account_id', '=', self.account_id.id), + ('partner_id', '=', self.env['res.partner']._find_accounting_partner(self.partner_id).id), + ('reconciled', '=', False), + '|', + '&', ('amount_residual_currency', '!=', 0.0), ('currency_id','!=', None), + '&', ('amount_residual_currency', '=', 0.0), '&', ('currency_id','=', None), ('amount_residual', '!=', 0.0)] if self.type in ('out_invoice', 'in_refund'): domain.extend([('credit', '>', 0), ('debit', '=', 0)]) type_payment = _('Outstanding credits')