Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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



Awatar
Odrzuć
Najlepsza odpowiedź

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


Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
lut 17
4090
2
paź 16
8583
2
kwi 25
1010
1
lis 24
1704
0
wrz 24
1114