summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroco-odoo <oco@odoo.com>2020-04-22 08:57:36 +0000
committeroco-odoo <oco@odoo.com>2020-04-23 14:37:35 +0000
commit70d1f903140d0ba5d902a1b2f7d2fe35791dd4e1 (patch)
tree11bcccc352fd892deafd4ea1453d64f7d4950b0c
parent91c3b1c0d7363a1cbc8ca8e895e6fc008ca25e38 (diff)
[FIX] account: reconciliation models: apply percentage properly for suggestion buttons
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 <smetl@users.noreply.github.com> Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
-rw-r--r--addons/account/models/account_reconcile_model.py10
1 files 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