Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
5736 Widoki

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?


Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Thank you!

Najlepsza odpowiedź

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 

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lis 23
2052
2
gru 23
5624
1
lis 22
2538
1
sie 22
2604
1
lip 20
3499