From 856b31719c69e7f022143ce39df7c6c43688beb9 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Fri, 13 Nov 2015 17:28:47 +0100 Subject: [PATCH] [FIX] product: _check_valid_attribute To check if the values set for the attribute are valid. opw:653945 --- addons/product/product.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/product/product.py b/addons/product/product.py index 8a2765a05f3..b4db0ba4cae 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -432,6 +432,14 @@ class product_attribute_line(osv.osv): 'value_ids': fields.many2many('product.attribute.value', id1='line_id', id2='val_id', string='Product Attribute Value'), } + def _check_valid_attribute(self, cr, uid, ids, context=None): + obj_pal = self.browse(cr, uid, ids[0], context=context) + return obj_pal.value_ids <= obj_pal.attribute_id.value_ids + + _constraints = [ + (_check_valid_attribute, 'Error ! You cannot use this attribute with the following value.', ['attribute_id']) + ] + #---------------------------------------------------------- # Products