[FIX] account: use refund repartition line when needed when applying a reconciliation model with a tax from a button

The fix made in https://github.com/odoo/odoo/pull/74427 was mistakenly not forward-ported. We reintroduce it here together with the fix that was made for it by https://github.com/odoo/odoo/pull/77589 .

Before this fix, the wrong repartition was used, and the tax_tag_invert computed for the move lines in this case was inconsistent, leading to wrong reporting.

closes odoo/odoo#78546

X-original-commit: 663bc7c0a0c0d7d16cd754bba5cea34bdb6315bf
Related: odoo/enterprise#21756
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2021-10-18 14:01:49 +00:00
committed by oco-odoo
parent 5652e7ee91
commit d60063e159
@@ -322,7 +322,9 @@ class AccountReconcileModel(models.Model):
self.ensure_one()
balance = base_line_dict['balance']
res = tax.compute_all(balance)
tax_type = tax.type_tax_use
is_refund = (tax_type == 'sale' and balance > 0) or (tax_type == 'purchase' and balance < 0)
res = tax.compute_all(balance, is_refund=is_refund)
new_aml_dicts = []
for tax_res in res['taxes']: