[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 <william-andre@users.noreply.github.com>
This commit is contained in:
wan
2019-09-23 13:00:22 +00:00
committed by fw-bot
parent 4abb293f3c
commit 4ec267bf79
@@ -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,