Odoo Help

0

How to display the name of the attribute in the sale.order.form?

By
Pascal Tremblay
on 4/20/15, 6:30 PM 1,335 views

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

0

Pascal Tremblay

--Pascal Tremblay--
1592
| 5 2 7
Alma, Canada
--Pascal Tremblay--


Pascal Tremblay
On 4/22/15, 3:09 PM

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



0
Jan
On 12/14/16, 1:47 PM

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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 4/20/15, 6:30 PM
Seen: 1335 times
Last updated: 12/14/16, 1:47 PM