diff --git a/bin/osv/orm.py b/bin/osv/orm.py index ebb11246e14..834b38e1e0c 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -2427,7 +2427,7 @@ class orm(orm_template): # call the 'set' method of fields which are not classic_write upd_todo.sort(lambda x, y: self._columns[x].priority-self._columns[y].priority) - # default element in context must be remove when call a one2many or many2many + # default element in context must be removed when call a one2many or many2many rel_context = context.copy() for c in context.items(): if c[0].startswith('default_'): @@ -2580,12 +2580,13 @@ class orm(orm_template): #End for field in vals: - if self._columns[field]._classic_write: - upd0 = upd0 + ',"' + field + '"' - upd1 = upd1 + ',' + self._columns[field]._symbol_set[0] - upd2.append(self._columns[field]._symbol_set[1](vals[field])) - else: - upd_todo.append(field) + if field in self._columns: + if self._columns[field]._classic_write: + upd0 = upd0 + ',"' + field + '"' + upd1 = upd1 + ',' + self._columns[field]._symbol_set[0] + upd2.append(self._columns[field]._symbol_set[1](vals[field])) + else: + upd_todo.append(field) if field in self._columns \ and hasattr(self._columns[field], 'selection') \ and vals[field]: @@ -2635,12 +2636,12 @@ class orm(orm_template): cr.execute('update '+self._table+' set parent_right=parent_right+2 where parent_right>%s', (pleft,)) cr.execute('update '+self._table+' set parent_left=%s,parent_right=%s where id=%s', (pleft+1,pleft+2,id_new)) - # default element in context must be remove when call a one2many or many2many + # default element in context must be removed when call a one2many or many2many rel_context = context.copy() for c in context.items(): if c[0].startswith('default_'): del rel_context[c[0]] - + for field in upd_todo: self._columns[field].set(cr, self, id_new, field, vals[field], user, rel_context) self._validate(cr, user, [id_new], context)