Issue 10509

Title
Wrong tax used for invoices on multicompany
Priority
bug
Status
resolved
Nosy list
acaubet, ced, pokoli, reviewbot, roundup-bot
Assigned to
pokoli
Keywords
review

Created on 2021-06-15.17:36:54 by acaubet, last changed 1 month ago by roundup-bot.

Messages

New changeset fe1bafbeec05 by Sergi Almacellas Abellana in branch '6.0':
Only return taxes for the current company
https://hg.tryton.org/modules/account_product/rev/fe1bafbeec05
New changeset 76dc325d6ca1 by Sergi Almacellas Abellana in branch 'default':
Only return taxes for the current company
https://hg.tryton.org/tryton-env/rev/76dc325d6ca1
New changeset b6cdedd37deb by Sergi Almacellas Abellana in branch 'default':
Only return taxes for the current company
https://hg.tryton.org/modules/account_product/rev/b6cdedd37deb
Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-06-16.08:25:46

The problem is that on_change_product returns taxes for all existing companies, which makes a record rule crash.

To reproduce the error you should do the following steps:

  1. Create a database with two companies
  2. Create a product and set an accounting category for it
  3. On the accounting category set the taxes for both companies
  4. Create an customer invoice and use product just created.

If the user only have access to a single company, the record rule is not satisfied so it produces an error
If the user has access to both companies, the taxes is duplicated

Here is review336421003 that fixes the problem for me.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-06-15.17:40:21

I do not understand the problem. There can be only one account per tax which is enforced to be in the same company as the tax.

Author: [hidden] (acaubet)
Date: 2021-06-15.17:36:54

In multicompany environment, the tax account is not properly selected (wrong invoice_account and credit_note_account) on changing product as we search by id, causing a domain error.
https://hg.tryton.org/modules/account_invoice/file/c804e958f11d/invoice.py#l2564

IIUC I assume that a accounting category must have both taxes defined like:
ACCOUNT CATEGORY: GENERAL 21
TAX LINE 1: COMPANY A - IVA 21%
TAX LINE 2: COMPANY B - IVA 21%
For me the proper way to select the appropriate tax is by filtering only the ones from the invoice company instead of using a id.
I'm still trying to figure out how it works and how to solve to submit a patch. Appreciate any help.

History
Date User Action Args
2021-06-23 22:59:20roundup-botsetkeyword: - backport
messages: + msg68393
2021-06-17 17:33:01roundup-botsetmessages: + msg68338
2021-06-17 17:32:57roundup-botsetmessages: + msg68337
nosy: + roundup-bot
status: testing -> resolved
2021-06-16 10:36:44reviewbotsetmessages: + msg68286
2021-06-16 09:29:14cedsetkeyword: + backport
2021-06-16 08:37:33reviewbotsetmessages: + msg68281
nosy: + reviewbot
2021-06-16 08:25:46pokolisetassignedto: pokoli
component: + account_product, - account_invoice
keyword: + review
messages: + msg68280
nosy: + pokoli
reviews: 336421003
status: need-eg -> testing
2021-06-15 17:40:21cedsetmessages: + msg68269
nosy: + ced
status: chatting -> need-eg
2021-06-15 17:36:54acaubetcreate

Showing 10 items. Show all history (warning: this could be VERY long)