From 4ec267bf79cd0fe1d88169bb892852410d0ab236 Mon Sep 17 00:00:00 2001 From: wan Date: Fri, 2 Aug 2019 12:33:13 +0000 Subject: [PATCH] [FIX] account: take into account the amount type of second reconciliation line The field second_amount_type was not taken into account when doing automatic reconciliation and 100% of the remaining amount was always used closes odoo/odoo#37282 X-original-commit: 8c2ed8849bdf5f6b84f63a01c1b27b83d31e3a8d Signed-off-by: wan --- addons/account/models/account_reconcile_model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py index 624767875a7..67de4ee148b 100644 --- a/addons/account/models/account_reconcile_model.py +++ b/addons/account/models/account_reconcile_model.py @@ -237,7 +237,11 @@ class AccountReconcileModel(models.Model): # Second write-off line. if self.has_second_line and self.second_account_id: - line_balance = balance - sum(aml['debit'] - aml['credit'] for aml in new_aml_dicts) + remaining_balance = balance - sum(aml['debit'] - aml['credit'] for aml in new_aml_dicts) + if self.second_amount_type == 'percentage': + line_balance = remaining_balance * (self.second_amount / 100.0) + else: + line_balance = self.second_amount * (1 if remaining_balance > 0.0 else -1) second_writeoff_line = { 'name': self.second_label or st_line.name, 'account_id': self.second_account_id.id,