diff options
| author | Nans Lefebvre <len@odoo.com> | 2019-07-19 11:32:07 +0000 |
|---|---|---|
| committer | Nans Lefebvre <len@odoo.com> | 2019-07-22 13:07:57 +0000 |
| commit | 088edee2ce7189a734dbddff27e733cba7366578 (patch) | |
| tree | a0ebe5c0f7f799543ee4b1c1be1933386f85b54f /addons/mail/wizard/mail_compose_message.py | |
| parent | 5e4c1b370123dee4e6d6a91cd9582ba41c4d8bd4 (diff) | |
[FIX] product: do not create duplicate variants
Create a product template Pt with attibutes A1, A2,
respectively with values Va1_1, Va1_2, and Va2.
This should make 2 variants, V1 and V2.
Sell some of these variants.
Then they can't be deleted since they are linked to orders/invoices/...
Now delete attribute A2. We know that:
Warning: adding or deleting attributes will delete and recreate existing
variants and lead to the loss of their possible customizations.
In fact, old variants are only archived instead of deleted:
for variant in variants_to_unlink: ... variant.write({'active': False})
as a fallback.
Now add again the attribute A2 to Pt.
It creates a new variant with the correct attributes.
Since the product is not active and has valid attributes and attribute values,
it is reactivated.
As a result we get the same variant twice.
Here we can simply add a check: if there is already an existing variant with
the same values, we can skip this activation.
We add a tiny little test to make sure that we have correct number of variants.
It's basically unreadable but somewhat commented.
fix coauthored with @rco-odoo
opw 2029985
closes odoo/odoo#35013
Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
0 files changed, 0 insertions, 0 deletions
