Skip to Content
Menu
This question has been flagged

Hello all,

Look here, for each product variants, values in the « attributes » column are displayed with this format « Attribute name : Attribute value ».



But here, in the Description field, we only see the « Attribute value ». But we ALSO want the format « Attribute name : Attribute value ».

For example, in image below, we would want this in the description field : « L510 - Chemise à manches courtes pour femme perso (Couleur du tissu : Bleu Royal) »



Please, ideas?


UPDATE #1

The name of the attribute is stocked in the model product.attribute. In the field name.

How to display this name in the description above?


UPDATE #2

It is clear that in the file /home/odoo-test/addons/product/product.py, we have this place that recup the name value in product.attribute.value. How to recup the name in product.attribute also?

variant = ", ".join([v.name for v in product.attribute_value_ids])

name = variant and "%s (%s)" % (product.name, variant) or product.name

Avatar
Discard
Author Best Answer

Here is our answer to this problem.


In the file /home/odoo-test/odoo-test/addons/product/product.py, we have to change this code :

        for product in self.browse(cr, SUPERUSER_ID, ids, context=context):

                variant = ", ".join([v.name for v in product.attribute_value_ids])

                name = variant and "%s (%s)" % (product.name, variant) or product.name


For this code :

        for product in self.browse(cr, SUPERUSER_ID, ids, context=context):

                variant = ''

                for item in product.attribute_value_ids:

                    variant += (' - ' + str(item.attribute_id.name) + ' : ' + item.name + ';\n')

                name = variant and "%s :\n%s" % (product.name, variant) or product.name



Avatar
Discard
Best Answer

Hi,

I was looking for a solution regarding this problem and came across an OCA-module that solves it: 

https://github.com/OCA/product-attribute/tree/15.0/product_variant_attribute_name_manager


Avatar
Discard
Best Answer

Hallo

As i expierenced error while starting odoo I found that it should be written like this:

For this code :
        for product in self.browse(cr, SUPERUSER_ID, ids, context=context):
                variant = ''
        for item in product.attribute_value_ids:
                    variant += (' - ' + str(item.attribute_id.name) + ' : ' + item.name + ';\n')
                name = variant and "%s :\n%s" % (product.name, variant) or product.name

Avatar
Discard
Related Posts Replies Views Activity
2
Feb 17
3402
2
Oct 16
7090
1
Nov 24
209
0
Sep 24
144
1
Aug 24
296