Created on 2022-02-09.12:24:47 by resteve, last changed 3 months ago by pokoli.
I guess your are not using 6.2 series as this should raise and error message since issue10841
For me the problem is that the ORM create multiple record of the same target in Many2Many when there is code to prevent that. Indeed I think it is because target_ids
should be made unique.
Also proteus should behave like the other client and keep only unique instance of record in Many2Many.
At the moment I published review395481002 related to invoices. Missing sales, etc...
Scenario:
When do on_change_product, len(taxes) == 3 but client only show two taxes: tax1 and tax2
Now, open a trytond-console, and do same operation.
>>> transaction.set_user(1)
>>> User = pool.get('res.user')
>>> context = User.get_preferences(context_only=True)
>>> transaction.set_context(context)
>>> Invoice = pool.get('account.invoice')
>>> invoice = Invoice(1)
>>> InvoiceLine = pool.get('account.invoice.line')
>>> Product = pool.get('product.product')
>>> product = Product(1)
>>> invoice_line = InvoiceLine()
>>> invoice_line.invoice = invoice
>>> invoice_line.product = product
>>> invoice_line.on_change_product()
> /home/raimon/projectes/nandev/049296/trytond/trytond/modules/account_invoice/invoice.py(2197)on_change_product()
-> self.taxes = taxes
(Pdb) taxes
[1, 30, 30]
(Pdb) c
Pool().get('account.invoice.line')(**{'taxes': [1, 30, 30], 'unit': 1, 'party': None, 'unit_digits': 0, 'company': 1, 'product': 1, 'invoice_type': None, 'account': 1588, 'invoice': 1})
>>> from decimal import Decimal
>>> invoice_line.quantity = Decimal(1)
>>> invoice_line.unit_price = Decimal(1)
>>> invoice_line.save()
>>> invoice_line.taxes
(Pool().get('account.tax')(1), Pool().get('account.tax')(30), Pool().get('account.tax')(30))
>>> Invoice.update_taxes([invoice])
>>> invoice.taxes
(Pool().get('account.invoice.tax')(1), Pool().get('account.invoice.tax')(2))
>>> invoice.untaxed_amount
Decimal('1.00')
>>> [t.base for t in invoice.taxes]
[Decimal('1.00'), Decimal('2.00')]
>>> [(t.tax, t.base) for t in invoice.taxes]
[(Pool().get('account.tax')(1), Decimal('1.00')), (Pool().get('account.tax')(30), Decimal('2.00'))]
SQL:
# select id, line, tax from account_invoice_line_account_tax;
id | line | tax
----+------+-----
7 | 3 | 1
8 | 3 | 30
9 | 3 | 30
Bug:
- Invoice line has three taxes: tax1, tax2 and tax2
- update_taxes(), the base from tax1 is 2.00 and not 1.00 (from total taxes in invoice line)
Reason:
New tax_ids are added in current list (extend). We need to set() unique taxes.
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-02-09 18:48:38 | pokoli | set | messages:
+ msg73982 nosy: + pokoli |
2022-02-09 14:16:37 | ced | set | component:
+ trytond, proteus, - account_invoice, purchase, sale messages: + msg73975 nosy: + ced title: Not expand tax when ID tax has in taxes (account invoice :: on_change_product) -> Many2Many values are not always unique |
2022-02-09 12:41:17 | reviewbot | set | messages:
+ msg73972 nosy: + reviewbot |
2022-02-09 12:37:45 | resteve | set | keyword:
+ review messages: + msg73971 reviews: 395481002 |
2022-02-09 12:24:47 | resteve | create |
Showing 10 items. Show all history (warning: this could be VERY long)