[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:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user