From 47ca07ba19b735de2a9c9a46c81899cafce1c374 Mon Sep 17 00:00:00 2001 From: Anton Chepurov Date: Thu, 26 Feb 2015 15:39:53 +0200 Subject: [PATCH] [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 --- addons/product/product.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index ad53e5dc3e0..1d02642de94 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -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))