Skip to Content
Menu
This question has been flagged

Hi all,

i'm trying to combine few custom fields to form product name in tree view. This is my code in py file


prod_name = fields.Char(compute="full_product_name", string="Product Name - CUSTOM")
def full_product_name(self): 
    for rec in self:
        rec.prod_name = rec.name + " " + rec.tension

The problem is I get error 

"TypeError: can only concatenate str (not "product.template.tension") to str"

Field "tension" is of type Manytoone 

How can I get value from this field to concatenate with my rec.name? Thank you!

Avatar
Discard
Author

Thank you Niyas,

I just had to add .name -> it's actually defined in class. I inherited this project and I'm real newbie in Odoo so I'm trying to figure it out :)

Best Answer

Hi,

Change this line:  rec.prod_name = rec.name + " " + rec.tension

as follows

        rec.prod_name = rec.name + " " + rec.tension.display_name

Thanks

Avatar
Discard
Related Posts Replies Views Activity
0
Feb 24
305
2
Oct 23
1095
0
Aug 20
2633
1
Aug 20
5085
2
May 20
5330