跳至内容
菜单
此问题已终结
1 回复
3505 查看

hi,

i want to create a master-detail form for data entry (like: Departments and Employees, the key column: id in Department (One2Many) and in Employee it is department_id (Many2One)), please point me to a simple example which uses only custom models and custom view.

regards

形象
丢弃
最佳答案

Hi,

To add a one2many field in odoo, you can refer this video explaining the same in details, see: How to Add One2many Fields In Odoo

Example:

class HRDepartment(models.Model):
_inherit = 'hr.department'

employee_ids = fields.One2many('hr.employee', 'department_id', string='Employees')


class HREmployee(models.Model):
_inherit = 'hr.employee'

department_id = fields.Many2one('hr.department', string='Department')


Thanks

形象
丢弃
编写者

thanks for help, but how i can use in a Master-Detail view (xml) which relatively done DML operations and Detail portion should be a editable tree view. also thanks for video link :)

相关帖文 回复 查看 活动
2
12月 20
8285
1
10月 23
2926
2
4月 23
2845
1
3月 23
2338
2
2月 25
40563