[FIX] product: sort attributes before checking existing variants
When generating the list of all needed variants, the attributes are sorted based on the order in field attribute_line_ids while, when comparing with existing variants, the order of the attributes on the product.product is the order on the field attribute_value_ids. As both order could be different (no direct relation), variants could be wrongly recreated instead of keeping existing one. Make sure the attribute lists are always sorted. Fixes #4361
This commit is contained in:
parent
ad4a269554
commit
47ca07ba19
|
@ -661,7 +661,7 @@ class product_template(osv.osv):
|
|||
temp_variants = []
|
||||
for variant in all_variants:
|
||||
for value_id in variant_id.value_ids:
|
||||
temp_variants.append(variant + [int(value_id)])
|
||||
temp_variants.append(sorted(variant + [int(value_id)]))
|
||||
if temp_variants:
|
||||
all_variants = temp_variants
|
||||
|
||||
|
@ -679,7 +679,7 @@ class product_template(osv.osv):
|
|||
variants_active_ids = []
|
||||
variants_inactive = []
|
||||
for product_id in tmpl_id.product_variant_ids:
|
||||
variants = map(int,product_id.attribute_value_ids)
|
||||
variants = sorted(map(int,product_id.attribute_value_ids))
|
||||
if variants in all_variants:
|
||||
variants_active_ids.append(product_id.id)
|
||||
all_variants.pop(all_variants.index(variants))
|
||||
|
|
Loading…
Reference in New Issue