odoo/odoo#121426

Created by fw-bot
Merged at 26cfd920ea57c439d7d425a2e22bf10f487d3c2d

Statuses:

label
odoo-dev:master-16.0-3224743-cydu-qdp-iODu-fw
head
4fcb6116550f610fd2224d7857af3e5911d47cb8
merged
2 years ago by Bugfix, Andrea Grazioso (agr)
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

[FW][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

Forward-Port-Of: #118510
Forward-Port-Of: #118443