[FIX] fields: when executing (4, *) operations on o2m fields, check the existence based on the sql model of the table.
If the o2m field linked to the o2m is stored on a different table (eg: model with _inherit), previous request would crash as the field do not exists in the '_table' sql table bzr revid: mat@openerp.com-20140327111241-klftr0s8v8i68nxp
This commit is contained in:
commit
85805282b6
|
@ -571,7 +571,10 @@ class one2many(_column):
|
|||
else:
|
||||
cr.execute('update '+_table+' set '+self._fields_id+'=null where id=%s', (act[1],))
|
||||
elif act[0] == 4:
|
||||
cr.execute("select 1 from {0} where id=%s and {1}=%s".format(_table, self._fields_id), (act[1], id))
|
||||
# table of the field (parent_model in case of inherit)
|
||||
field_model = self._fields_id in obj.pool[self._obj]._columns and self._obj or obj.pool[self._obj]._all_columns[self._fields_id].parent_model
|
||||
field_table = obj.pool[field_model]._table
|
||||
cr.execute("select 1 from {0} where id=%s and {1}=%s".format(field_table, self._fields_id), (act[1], id))
|
||||
if not cr.fetchone():
|
||||
# Must use write() to recompute parent_store structure if needed and check access rules
|
||||
obj.write(cr, user, [act[1]], {self._fields_id:id}, context=context or {})
|
||||
|
|
Loading…
Reference in New Issue