[IMP] models: add the base model as an abstract model in the registry

The model `base` is implicitly inherited by all models, and can be extended as
any other model.
This commit is contained in:
Raphael Collet
2016-02-04 15:52:06 +01:00
parent 0040632696
commit 53572ba4c6
2 changed files with 11 additions and 0 deletions
+7
View File
@@ -50,6 +50,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
#
# IMPORTANT: this must be the first model declared in the module
#
class Base(models.AbstractModel):
""" The base model, which is implicitly inherited by all models. """
_name = 'base'
class unknown(models.AbstractModel):
"""
Abstract model used as a substitute for relational fields with an unknown
+4
View File
@@ -612,6 +612,10 @@ class BaseModel(object):
# determine the model's name
name = cls._name or (len(parents) == 1 and parents[0]) or cls.__name__
# all models except 'base' implicitly inherit from 'base'
if name != 'base':
parents = list(parents) + ['base']
# create or retrieve the model's class
if name in parents:
if name not in pool: