Hi everyone,
I'm working on two add-ons. In one add-on, I define an abstract model to use as a base (A), and I also define two concrete models that inherit from this base model (B and C)
In another add-on, I use the base model as a relation in another model (D). My idea was that this would display the items from the concrete models. However, I get an error when I try to create model D
class A(models.AbstractModel):
_name = "a"
class B(models.Model):
_name = "b"
_inherit = "a"
class C(models.Model):
_name = "c"
_inherit = "a"
class D(models.Model):
a_id = fields.Many2one("a", string="A")
The error:
File "/odoo/odoo/models.py", line 4045, in _read_format vals[name] = convert(record[name], record, use_display_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/odoo/odoo/fields.py", line 3295, in convert_to_read return value.id ^^^^^^^^ AttributeError: 'A' object has no attribute 'id'
I tried changing model A to a concrete model, and that made the error disappear. However, it doesn't show the children B and C when I try to create model D. I also tried instantiating model A when creating models B and C. In this case, it appears when I create model D, but I lose the ability to search and filter by features of models B and C.
Is this possible, or am I wrong in trying to make this relationship with the abstract model?
Any pointers appreciated!