コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
5769 ビュー

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
2088
2
12月 23
5669
1
11月 22
2565
1
8月 22
2630
1
7月 20
3520