improvement in checking for model existance

bzr revid: mga@tinyerp.com-20090511111738-00ornn57eh8jjfzp
This commit is contained in:
Mantavya Gajjar 2009-05-11 16:47:38 +05:30
parent 2bbab69820
commit 28a970761a
1 changed files with 6 additions and 7 deletions

View File

@ -244,13 +244,12 @@ 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_' !"))
model_ids = self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])])
if model_ids:
if self.pool.get(vals['model']):
self.pool.get(vals['model']).__init__(self.pool, cr)
self.pool.get(vals['model'])._auto_init(cr, {})
else:
raise except_orm(_('Error'), _("Model %s Does not Exist !" % vals['relation']))
if 'relation' in vals 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']):
self.pool.get(vals['model']).__init__(self.pool, cr)
self.pool.get(vals['model'])._auto_init(cr, {})
return res
ir_model_fields()