[FIX] Use _unknown model for missing models in relation fields
During a migration of database, it is possible that some custom field ("x_", state is 'manual') are relational to model from a module that is not provided. Note: this used to work in Odoo 7.0 but crashed in 8.0. Closes #3877
This commit is contained in:
parent
4e9613609d
commit
55fa50891d
|
@ -62,6 +62,13 @@ def _in_modules(self, cr, uid, ids, field_name, arg, context=None):
|
|||
result[k] = ', '.join(sorted(installed_modules & set(xml_id.split('.')[0] for xml_id in v)))
|
||||
return result
|
||||
|
||||
class unknown(models.AbstractModel):
|
||||
"""
|
||||
Abstract model used as a substitute for relational fields with an unknown
|
||||
comodel.
|
||||
"""
|
||||
_name = '_unknown'
|
||||
|
||||
class ir_model(osv.osv):
|
||||
_name = 'ir.model'
|
||||
_description = "Models"
|
||||
|
|
|
@ -1372,8 +1372,10 @@ class _Relational(Field):
|
|||
|
||||
def _setup(self, env):
|
||||
super(_Relational, self)._setup(env)
|
||||
assert self.comodel_name in env.registry, \
|
||||
"Field %s with unknown comodel_name %r" % (self, self.comodel_name)
|
||||
if self.comodel_name not in env.registry:
|
||||
_logger.warning("Field %s with unknown comodel_name %r"
|
||||
% (self, self.comodel_name))
|
||||
self.comodel_name = '_unknown'
|
||||
|
||||
@property
|
||||
def _related_domain(self):
|
||||
|
|
Loading…
Reference in New Issue