Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Error in inheritance a model with Many2many field

Avatar
odoo
1 Comment
Avatar
Discard
2 Answers
0
Avatar
odoo
Best Answer

Hello,

Use only _inherit,

  • Remove the _name attribute and just extend the existing model. This is the most common approach when you just want to add fields to an existing model.

    When you use both _name and _inherit, Odoo creates a new model that tries to use the same table names as the original model.

  • Many2many fields automatically generate table names based on the model names, causing conflicts.

    Hope this helps!

1 Comment
Avatar
Discard
Avatar
odoo
-

It worked fine. Thanks!

0
Avatar
odoo
Best Answer

Hi,


Remove _name = 'fabrica3.mrpworkorder' from your model

Keep only _inherit = 'mrp.workorder'

This way, you're extending the existing mrp.workorder model

The error happens because defining a new model with _name reuses internal Many2many fields incorrectly

Only use _name if you're creating a completely new model (not needed here)

After removing _name, your model will load without the Many2many field conflict



Hope it helps.

1 Comment
Avatar
Discard
Avatar
odoo
-

It worked fine. Thanks!