Hi All, let me explain my scenario:
I am developing new custom module where I have two child models "B" and "C" _inherit from parent model "A". The main model "A" has a One2many relationship with another model "D". Odoo 14 raise an error [*] when interacting with "field_ids" added to the views of "B" or "C". However, the error does not occur when declaring the One2many relationship field between, for example, the child model "B" and the model "D" ! but this does not make sense to me as I understood inheritance, because in this case the model "D" must have multiple Many2one fields ("B_id" and "C_id") referring to child models "B" and "C" respectively instead of a single Many2one field "A_id" referring to the main model "A".
Why is the One2many relationship not supported in the _inherit mode in Odoo14?
-----------------------------
* File "C:\Odoo14\odoo\odoo\models.py", line 5168, in _update_cache raise ValueError("Invalid field %r on model %r" % (e.args[0], self._name)) Exception
If i understood the error, Odoo excepted to find the fields of the child model in the main model ?!
Hi,
if i understood well your issue, When you add the O2M field in a view declared in module where B (or C ) exists, Odoo raises an error ?
If yes, did you add the dependancy between modules where O2M is declared and B ( or C ) is defined ? == Module where B is defined must depend on module where O2M is declared.
Hi Ibrahim,
All the models A, B, C and D are part of the same module !
if they are in the sale module, then why you inherit multiple times a model that's already defined ? you can work directly with A..
Example:
In the same module, file 1, I define model A
in file 2, if I need to work with A, I shouldn't redefine a new model B with _inherit from A ( what you're doing right now )
you can go back to file 1, model A and add the fields you want..
hope it's clear.
Dear Ibrahim, the models in the above scenario are part of completely a new custom module I am currently developing and are not part of existing Odoo modules. Thank you.