From 70d1f903140d0ba5d902a1b2f7d2fe35791dd4e1 Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Wed, 22 Apr 2020 08:57:36 +0000 Subject: [PATCH] [FIX] account: reconciliation models: apply percentage properly for suggestion buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The buttons created in the reconciliation widget by the reconciliation models did not apply the percentage of their lines correctly. Example of the behavior before the fix : 1) Create a 'writeoff_button' reconcile model, with two lines of 50% on distinct accounts 2) Create a statement line of 100€ 3) Open the reconciliation widget and apply the model created in 1) to the line made in 2) => Two lines are created, 50€ and 25€. They should both be 50€. closes odoo/odoo#49963 X-original-commit: d3bd67fa12d85515fa6683f7b5d9ae114056bb62 Signed-off-by: Laurent Smet Signed-off-by: oco-odoo --- addons/account/models/account_reconcile_model.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py index d5790d0d654..c67f471c90d 100644 --- a/addons/account/models/account_reconcile_model.py +++ b/addons/account/models/account_reconcile_model.py @@ -257,13 +257,15 @@ class AccountReconcileModel(models.Model): if self.rule_type == 'invoice_matching' and (not self.match_total_amount or (self.match_total_amount_param == 100)): return [] + line_currency = st_line.currency_id or st_line.journal_id.currency_id or self.company_id.currency_id + if line_currency.is_zero(residual_balance): + # No writeoff needs to be done for a full reconciliation + return [] + lines_vals_list = [] for line in self.line_ids: - if not line.account_id or st_line.company_currency_id.is_zero(residual_balance): - return [] - if line.amount_type == 'percentage': balance = residual_balance * (line.amount / 100.0) elif line.amount_type == "regex": @@ -288,8 +290,6 @@ class AccountReconcileModel(models.Model): } lines_vals_list.append(writeoff_line) - residual_balance -= balance - if line.tax_ids: writeoff_line['tax_ids'] = [(6, None, line.tax_ids.ids)] tax = line.tax_ids