odoo/odoo — pull request #2201 by rha-odoo (2014-09-05 05:22:48+00:00)
Title: [FIX] invoice: Tax Amount in Journal Item is wrong when creating a multi...

... currency invoice with tax and manually change the Tax Amount from the Tax Declaration line; OPW Ticket:611474

Issue: For the invoice created with tax in another currency(than a base), in the journal entries, "Tax Amount" for tax journal entry is wrong.

Steps:
- Install account application, enable multi currency setting, and do all required settings to create invoice in another currency
- create a customer invoice in USD(EUR is the base), add an invoice line with any tax
- save or update invoice, you will have tax allocation entry into Tax Declaration lines
- edit invoice and modify the tax amount, save the invoice and validate
- check journal entry, the tax journal item will have wrong Tax Amount

Root of the problem:
While you change the tax amount on the invoice from tax declaration line, the onchange of amount is triggred which convert the amount(from USD) into the company currency EUR two times. because function compute() having paramater as "amount * factor", and "amount * facto" itself do the currency conversion. So it should be either only "amount * factor" or the compute()

Fix:
remove compute() call (else block will do), and in case you do not have tax applied on invoice line and you manually add tax line into tax declaration then that case "if block" will be needed because we will not have "factor"(indeed we get factor=1) so compute() call will do.