Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1253 Lượt xem

I get this error when I try install a module with the xml demo data below


<?xml version="1.0" encoding="utf-8"?>
<odoo>   
​<data noupdate="1">       
​<record id="comp1" model="res.company">           
​<field name="name">Test Company</field>           
​<field name="currency_id" ref="base.USD"/>       
​</record>       
​<record id="dept1" model="hr.department">           
​<field name="name">Service</field>           
​<field name="company_id" ref="comp1"/>       
​</record>       
​<record id="emp1" model="hr.employee">           
​<field name="name">John</field>           
​<field name="department_id" ref="dept1"/>       
​</record>   
​</data>
</odoo>

Validation Error

The operation cannot be completed: 
- Create/update: a mandatory field is not set. 
- Delete: another model requires the record being deleted. If possible, archive it instead. 
 

Model: Employee (hr.employee) 
Field: Department (department_id)


If i switch ref="comp1" to ref=" base.main_company", it works fine. Why does another company not work? I cant find any code that removes the department for some reason when creating. Im on v17


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I realized I need to pass the company_id to the employee record as well

​ ​<record id="emp1" model="hr.employee">           

​ ​ ​<field name="name">John</field>           

​ ​ ​<field name="department_id" ref="dept1"/>       

​ ​<field name="company_id" ref="comp1"/> 

​ ​</record>   

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
961
4
thg 5 25
2716
2
thg 5 25
6143
1
thg 3 25
1813
4
thg 3 25
4705