Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
5738 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor

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

Thank you!

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
lis 23
2053
2
pro 23
5624
1
lis 22
2539
1
srp 22
2604
1
čvc 20
3499