This question has been flagged
2 Replies
3669 Views

In an automated action, I would like to copy the name of the filed product_id field (using the notation .name) from the mrp.production model to a text custom field in the project.task model.
So using the product_id.name the system returns the name of the "product" (template) instead on the name of the "product variant" while in the same automated action the notation .id (product_id.id) returns, as expected, the ID  of the "Product Variant" .

What's the correct syntax to use?


Avatar
Discard
Best Answer

Hi,

In the mrp.production model, the product_id is a many2one field of product.product model, so if you try to get the record.product_id.name from mrp.production model, you will get the value of the name field, also you can try to get .display_name and see whether it satisfies what you need.


record.product_id.display_name


If this is not worked for you, please elaborate the question with the codes you have tried.


Thanks

Avatar
Discard
Author

Using record.product_id.display_name I get the name of the product variant.

Thank you!

Best Answer

It's because Name field is defined in the product.template not in the product.product.

product.product inheits all the properties of Product(Template), that's why you can get the name of the Templates when you try to access name of produt.product(Variant). 

If you will change name of any single product.product (variant) then Name will be updated for all the variants as well as of Template.  

You can access display_name field of product.product (variant) which gives you variant

[Internal Reference] Template Name 

Avatar
Discard