Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
1477 Vizualizări

Hi!

I would like to know how can I create a data for the seeder please ?

- for one2many

- for many2many


Currently I have a data:


category.xml
<record id="category_1" model="product.category">
<
fieldname="name">Category 1field>


product.xml
<record id="product_1" model="product.product">
<
fieldname="name">Product 1field>


I would like to attach a category on product

And on the many2many relation, how can I create a seeder with insert id ?

Thank you so much for your help!

Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

To create a data file for many2many and one2many, first you need to create data in the one2many or many2many model. Then link that data file to the main model.

<record id="employee_category_2" model="hr.employee.category">
          <field name="name">Sales</field>
</record>


<record id="employee_fp" model="hr.employee">
          <field name="name">Pieter Parker</field>
          <field name="user_id" ref="base.user_root"/>
          <field name="department_id" ref="dep_management"/>
          <field name="job_id" ref="hr.job_ceo"/>
<field name="category_ids" eval="[(6, 0, [ref('employee_category_2')])]"/>
          <field name="work_location">Building 1, Second Floor</field>
<field name="work_phone">+3281813700</field>
<field name="work_email">pieter@openerp.com</field>
<field name="image" type="base64" file="hr/static/img/employee_fp-image.jpg"/>
</record>


You can refer more from this link:

https://github.com/odoo/odoo/blob/9.0/addons/hr/hr_demo.xml" target="_blank" data-saferedirecturl="https://github.com/odoo/odoo/blob/9.0/addons/hr/hr_demo.xml

" rel="ugc">https://www.google.com/url?q=https://github.com/odoo/odoo/blob/9.0/addons/hr/hr_demo.xml&source=gmail&ust=1691503901030000&usg=AOvVaw0qj7PFExwbprYOcbgO6-rE">https://github.com/odoo/odoo/blob/9.0/addons/hr/hr_demo.xml

Hope it helps

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
aug. 22
2282
0
mai 17
6870
1
mar. 15
3487
2
mar. 15
3887
0
dec. 24
473