The attributes doesn't work when product is viewed outside the template
Use a Function field to always get the attribute_set. issue4209 review12581002
This commit is contained in:
1 parent
7253c1fb32
commit
18b0b2ca06
1 file changed
+13
-4
+13
-4
@@ -42,9 +42,18 @@ class Product:
|
||||
__name__ = 'product.product'
|
||||
attributes = fields.Dict('product.attribute', 'Attributes',
|
||||
domain=[
|
||||
('sets', '=',
|
||||
Eval('_parent_template', {}).get('attribute_set', -1)),
|
||||
('sets', '=', Eval('_parent_template', {}).get('attribute_set',
|
||||
Eval('attribute_set', -1))),
|
||||
],
|
||||
states={
|
||||
'readonly': ~Eval('_parent_template', {}),
|
||||
})
|
||||
'readonly': (~Eval('attribute_set')
|
||||
& ~Eval('_parent_template', {}).get('attribute_set')),
|
||||
},
|
||||
depends=['attribute_set'])
|
||||
attribute_set = fields.Function(fields.Many2One('product.attribute.set',
|
||||
'Set'), 'on_change_with_attribute_set')
|
||||
|
||||
@fields.depends('template')
|
||||
def on_change_with_attribute_set(self, name=None):
|
||||
if self.template and getattr(self.template, 'attribute_set', None):
|
||||
return self.template.attribute_set.id
|
||||
Reference in new issue
Block a user