跳至内容
菜单
此问题已终结
2 回复
5063 查看

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?


形象
丢弃
最佳答案

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

形象
丢弃
编写者

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

Thank you!

最佳答案

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 

形象
丢弃
相关帖文 回复 查看 活动
1
11月 23
1447
2
12月 23
4972
1
11月 22
1987
1
8月 22
2159
1
7月 20
2992