[FIX] Copy() of ir_model_fields corected
authorJay (Open ERP) <jvo@tinyerp.com>
Thu, 15 Apr 2010 14:03:34 +0000 (19:33 +0530)
committerJay (Open ERP) <jvo@tinyerp.com>
Thu, 15 Apr 2010 14:03:34 +0000 (19:33 +0530)
lp bug: https://launchpad.net/bugs/559346 fixed

bzr revid: jvo@tinyerp.com-20100415140334-amnevq3bxd4f37nt

bin/addons/base/ir/ir_model.py
bin/osv/orm.py

index 97d167c..d870c8a 100644 (file)
@@ -251,7 +251,7 @@ 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 not context:
+        if context is None:
             context = {}
         if context and context.get('manual',False):
             vals['state'] = 'manual'
@@ -260,7 +260,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']):
index 571ac9e..a749b1c 100644 (file)
@@ -374,7 +374,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,