From aa3f25b940f4d33b140d260508f74c7019ff7721 Mon Sep 17 00:00:00 2001 From: Vincent Van Rossem Date: Wed, 23 Sep 2020 11:07:28 +0200 Subject: [PATCH] [ADD] beesdoo_account: _compute_residual() override `sign` depends on the `amount_total` value --- beesdoo_account/models/account_invoice.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/beesdoo_account/models/account_invoice.py b/beesdoo_account/models/account_invoice.py index 886cfa5..f115747 100644 --- a/beesdoo_account/models/account_invoice.py +++ b/beesdoo_account/models/account_invoice.py @@ -5,6 +5,18 @@ from odoo.exceptions import UserError class AccountInvoice(models.Model): _inherit = "account.invoice" + @api.one + @api.depends( + 'state', 'currency_id', 'invoice_line_ids.price_subtotal', + 'move_id.line_ids.amount_residual', + 'move_id.line_ids.currency_id') + def _compute_residual(self): + super(AccountInvoice,self)._compute_residual() + sign = self.amount_total < 0 and -1 or 1 + self.residual_company_signed *= sign + self.residual_signed *= sign + self.residual *= sign + @api.multi def action_invoice_open(self): if self.user_has_groups(