3

I would like to construct an object (objA), which over the course of its existence takes on many different types of status (objB). However, each different type of status is its own beast which varies depending on its type (type1, type2, type3, ...).

Apparently Odoo / OpenERP does not support polymorphism so the introduction of the intermediary status objB is intended to cloak the different types of status with hopes that objA may have a One2Many field consisting of its ''status history''.

Now, I am stuck with the notions of inheritance that Odoo documentation describes as Traditional vs Delegation and am unsure which is which. Furthermore, if this type of manipulation is possible, will it be possible that all attributes can be realized in objA's form-view?

My only guess is something like as follows;

class ObjA(models.Model):
    _name = 'obja'
    generic_attribute = fields.Char(string="Generic Attribute", default="Anything")
    status_history = fields.One2many('obja.status', 'obja.id', string="History")

class Status(models.Model):
    _name = 'obja.status'
    generic_status_attribute = fields.Date(string="Status start")
    _inherits = ['status.type1', 'status.type2', 'status.type3']

class Type1(models.Model):
    _name = 'status.type1'

class Type2(models.Model):
    _name = 'status.type3'

class Type3(models.Model):
    _name = 'status.type3'
BenSmith
  • 163
  • 1
  • 9
  • 3
    I think there possibly is an example in odoo itself, which is implementing your requirement. `ir.ui.menu` can take different types (models) of ir.actions, which are inheriting `ir.actions.actions`. You can find the classes in base/ir. – CZoellner Jun 24 '16 at 15:19

0 Answers0