当用户使用One2many关系字段创建新信息时,Odoo会自动填充网格吗?
这是我的示例自动填充
def getCheckListId(self):
self.env.cr.execute("select 1 employee_id,1 PARAM1,1 PARAM2,1 PARAM3,1 PARAM3,1 PARAM4 from hr_employee_checklist ")
checklistTemplates = self.env.cr.fetchall()
return checklistTemplates
此功能将在One2ManyFields
中用作默认值employee_checklists = fields.One2many('hr.employee_checklist','employee_id', readonly=False,copy=False, default = getCheckListId)
但我有一个错误 错误是
属性错误:' str'对象没有属性' iteritems'
有人可以帮我解决这个问题或其他方法在Odoo中填充网格
答案 0 :(得分:0)
<强> One2many 强>
One2many场;此类字段的值是recordset
中所有记录的comodel_name
,因此字段inverse_name
等于当前记录。
参数
所以,One2many字段总是包含comodel的引用值,你只需要给出那个关系字段的id,剩余的东西将由odoo引擎自己维护。
@api.model
def getCheckListId(self):
return self.env['hr.employee.checklist'].search([]).ids