我创建了一个函数,当父表中的某些字段发生变化时,将数据映射到子表中,当父表字段发生变化时数据保存在子表中我可以在数据库中看到它,但问题是数据没有显示在子表的树网格视图中。
这是我的代码:
def on_change_test(self, cr, uid, ids, district_id,
select_db,sub_district_id,ward, context = None):
obj_master = self.pool.get('Parent_table')
MasterID = obj_master.create(cr, uid,
{'district_id':district_id,
'sub_district_id':sub_district_id,
'to_master_ward':ward,
'select_db':select_db})
obj_child = self.pool.get('Child_table')
obj_child.create(cr, uid,
{'sex':'male',
'wardID':MasterID,
'from_ward':child_line_id.address_id.name,
'Parent_ID':child_line_id.id,
'date_o_birth':child_line_id.date_of_birth})
return True
答案 0 :(得分:2)
def create(self, cr, uid, vals, context=None):
obj_master = super(parent_table,self).create(cr,uid, vals, context=context)
obj_child = self.pool.get('child.table')
obj_child.create(cr, uid,{'field_name':obj_child.field_value......})
您的方法不正确,您可以通过使用超级调用覆盖create方法
来实现