Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
783 Widoki

Hello!

I am trying to create my first custom app in Odoo. The app name is 'fabrica3' with a model below:

class MRPWorkorder(models.Model):​
​_name = 'fabrica3.mrpworkorder'
​_inherit = 'mrp.workorder'

​employee = fields.Many2one('hr.employee')
​name = fields.Char(compute='_get_name', store=True)

But when I try to activate this app I receive the message

TypeError: Many2many fields fabrica3.mrpworkorder.blocked_by_workorder_ids and mrp.workorder.blocked_by_workorder_ids use the same table and columns

But I dont use the field blocked_by_workorder_id.

I am using v18.

Can anyone help me .


Awatar
Odrzuć
Najlepsza odpowiedź

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!

Awatar
Odrzuć
Autor

It worked fine. Thanks!

Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

It worked fine. Thanks!

Powiązane posty Odpowiedzi Widoki Czynność
2
cze 25
3036
0
wrz 19
3278
4
lut 25
2448
3
lis 24
30038
1
sie 24
2050