diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index 40c12461bc8..ffb2d31b909 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -260,6 +260,8 @@ class ir_model_fields(osv.osv): if 'model_id' in vals: model_data = self.pool.get('ir.model').browse(cr, user, vals['model_id']) vals['model'] = model_data.model + if context is None: + context = {} if context and context.get('manual',False): vals['state'] = 'manual' res = super(ir_model_fields,self).create(cr, user, vals, context) @@ -267,7 +269,7 @@ class ir_model_fields(osv.osv): if not vals['name'].startswith('x_'): raise except_orm(_('Error'), _("Custom fields must have a name that starts with 'x_' !")) - if 'relation' in vals and not self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])]): + if vals.get('relation',False) and not self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])]): raise except_orm(_('Error'), _("Model %s Does not Exist !" % vals['relation'])) if self.pool.get(vals['model']): diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 6a96f22ff40..76bca677224 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -276,7 +276,7 @@ class browse_record(object): else: new_data[n] = data[n] self._data[data['id']].update(new_data) - + if not name in self._data[self._id]: #how did this happen? self.logger.notifyChannel("browse_record", netsvc.LOG_ERROR, @@ -438,7 +438,7 @@ class orm_template(object): 'name': k, 'field_description': f.string.replace("'", " "), 'ttype': f._type, - 'relation': f._obj or 'NULL', + 'relation': f._obj or '', 'view_load': (f.view_load and 1) or 0, 'select_level': tools.ustr(f.select or 0), 'readonly':(f.readonly and 1) or 0,