当用户使用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)但是我有个错误,错误是
AttributeError:'str‘对象没有属性’迭代项‘
有人能帮我解决这个问题或其他方法来填充Odoo中的Grid吗?
发布于 2015-09-25 05:30:40
One2many
One2many字段;这样一个字段的值是comodel_name中所有记录的recordset,因此字段inverse_name等于当前记录。
参数
因此,One2many字段总是包含comodel的引用值,您只需要给出那个关系字段的it,剩余的东西将由odoo it self维护。
@api.model
def getCheckListId(self):
return self.env['hr.employee.checklist'].search([]).idshttps://stackoverflow.com/questions/32755493
复制相似问题