[FIX] product: name_get of product.attribute.value
authorChristophe Matthieu <chm@odoo.com>
Thu, 6 Nov 2014 17:44:19 +0000 (18:44 +0100)
committerMartin Trigaux <mat@odoo.com>
Fri, 7 Nov 2014 11:03:47 +0000 (12:03 +0100)
name was confusing for bom and product if the value of the attribute is display without the attribute name
added key in context to keep the previous behaviour (e.g. in product view where the attribute name is present)

addons/product/product.py
addons/product/product_view.xml

index 8f4921f..7060a4f 100644 (file)
@@ -365,6 +365,14 @@ class product_attribute_value(osv.osv):
                     'price_extra': value,
                 }, context=context)
 
+    def name_get(self, cr, uid, ids, context=None):
+        if context and not context.get('show_attribute', True):
+            return super(product_attribute_value, self).name_get(cr, uid, ids, context=context)
+        res = []
+        for value in self.browse(cr, uid, ids, context=context):
+            res.append([value.id, "%s: %s" % (value.attribute_id.name, value.name)])
+        return res
+
     _columns = {
         'sequence': fields.integer('Sequence', help="Determine the display order"),
         'name': fields.char('Value', translate=True, required=True),
index 4eb42e3..02dd569 100644 (file)
                                 <field string="List of Variants" name="product_variant_count" widget="statinfo" />
                             </button>
                         </div>
-                        <field name="attribute_line_ids" widget="one2many_list">
+                        <field name="attribute_line_ids" widget="one2many_list" context="{'show_attribute': False}">
                             <tree string="Variants" editable="bottom">
                                 <field name="attribute_id"/>
                                 <field name="value_ids" widget="many2many_tags" options="{'no_create_edit': True}" domain="[('attribute_id', '=', attribute_id)]" context="{'default_attribute_id': attribute_id}"/>