odoo/odoo#118443

Created by Accounting, Quentin De Paoli (qdp)
Merged at 932d0382b5a4a5d0d91dd532940bc2ed8d0c13da

Statuses:

label
odoo-dev:16.0-3224743-cydu-qdp
head
c10f79c839ba4d70b285bb62d558a88cb7f0cb30
merged
2 years ago by Accounting, Quentin De Paoli (qdp)
odoo/odoo
16.0 #118443
saas-16.1 #118499
saas-16.2 #118510
17.0
18.0
saas-18.1
saas-18.2
saas-18.3
master #121426

[FIX] account: Fix tax recomputation with tax cash rounding

Step to reproduce:

1. Set up Cash rounding for Tax: Accounting> Configuration > cash
   rounding
2. Set up recurrent product: Service type - Prepaid - tax VAT 7.7
3. Create an order with that product - set price of 45 (to have the
   rounding) > confirm order > Create an invoice
4. In the new invoice > "Other info" tab > add the rounding method
5. Change the quantity

Current behavior: tax doesn't update if there is a rounding line
Expected: tax should be updated.

Why:
What happens is that odoo trying to update the new tax amount on the
wrong line (the rounded tax amount line).

That's because the `existing_after` dict is poorly defined. It is
defined by the `existing()` inner function of `_sync_dynamic_line`
thanks to the "tax_key" of each line.​

The two account move lines (VAT line and rounding on the VAT line) share
the same tax_key,​ and because of that the VAT line is overwritten by
the rounding line in the dict returned by`existing()`.

Then the cash rounding is recomputed from the VAT line(that still holds
the outdated values) and overwrites the updated values on the rounding
line.

Solution:
Adding the type of line in the tax_key to differentiate between a VAT
line and a rounding VAT line

opw-3224743

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr