Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd

I know how to define demo data using XML files and usage of the corresponding xml ids. However, I am not able to understand how most of the product.template records are defined in the odoo product module demo data.


For example, In Odoo v15.0, I can see the definition of below record in product/data/product_demo.xml

❯ grep product_product_27 product/
product/data/product_demo.xml
489:    <record id="product_product_27" model="product.product">   


However, I am not able to find the definition of product_product_27_product_template (product.template) anywhere, even though it is being referenced in the same file,

❯ grep product_product_27_product_template product/
product/data/product_demo.xml
748:    <field name="product_tmpl_id" ref="product_product_27_product_template"/>       


1. Where is product_product_27_product_template defined (product.template) defined?

2. How is it linked with product_product_27 (product.product)?


Any help would be greatly appreciated. Thanks in advance.

Avatar
Annuleer
Auteur Beste antwoord

Posting the answer from StackOverflow (https://stackoverflow.com/questions/77275373/odoo-how-are-product-template-records-created-and-linked-to-product-product-rec/77281793#77281793)

When Odoo loads product/data/product_demo.xml file and creates the Drawer record (id=product_product_27), it will compute the parent record external id based on the following expression:

'xml_id': f"{data['xml_id']}_{parent_model.replace('.', '_')}",

Odoo will add XML ids for parent records that have just been created

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
feb. 25
1388
2
jan. 24
19996
0
mei 23
448
1
aug. 21
4743
2
dec. 19
4001