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

i have this new model that inherit the project.project model:

 

class RealEstateProject(models.Model):

    _name = 'real.estate.project.classical'

    _inherit = 'project.project'

    _description = 'Real Estate Projects'

 

after running it appears this problem of many2many fields  :

 

TypeError: Many2many fields real.estate.project.classical.favorite_user_ids and project.project.favorite_user_ids use the same table and columns


i added this field to my new model

 

favorite_user_ids = fields.Many2many(

        'res.users',

        'real_estate_project_favorite_user_rel',

        'project_id',

        'user_id',

        string='Favorite Users'

    )

 

then i have another field 

TypeError: Many2many fields real.estate.project.classical.type_ids and project.project.type_ids use the same table and columns

 

so i add it

 

type_ids = fields.Many2many(

        'project.task.type',

        'real_estate_type_rel', 

        'project_id',

        'type_id',

        string='Types'

    )

 

now after running i have this problem of foreign key:

psycopg2.errors.UndefinedColumn: column "real_estate_project_classical_id" referenced in foreign key constraint does not exist

 

How can i solve this please !!

Awatar
Odrzuć
Najlepsza odpowiedź

When inherit a model in Odoo, it keeps the existing fields and their definitions, including Many2many fields. This means that if you're trying to define new Many2many fields in your inherited model that share the same database table and columns as those in the original model there will be conflict.

Awatar
Odrzuć

hi, thank you
so what can be the solution

Remove the redefinition of the favorite_user_ids and type_ids fields in your RealEstateProject model.

Powiązane posty Odpowiedzi Widoki Czynność
2
sie 23
43001
1
mar 15
10262
1
kwi 24
2073
5
sie 23
57319
7
gru 23
26118