[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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user