Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
2375 Zobrazení

Error: psycopg2.errors.ForeignKeyViolation: insert or update on table "pma_contract" violates foreign key constraint "pma_contract_lessor_fkey"


DETAIL:  Key (lessor)=(2) is not present in table "pma_contract_lessor_profile".


In model "pma.contract.lessor.profile", I create a new field: 


 contract_id = fields.One2many("pma.contract", "lessor", string="Contract member")


In model "pma_contract, I changed:

    lessor = fields.Many2one("res.users",
​string="Party A (Lessor)",
​store=True, required=True,  tracking=True)

to:

 
    lessor = fields.Many2one("pma.contract.lessor.profile",
​string="Party A (Lessor)",
​ store=True,  required=True,  tracking=True
Avatar
Zrušit
Nejlepší odpověď

Hi,

The issue is that the first column of 'lessor' might not be removed from the database when you change the field attribute(comodel_name). It is better to remove the first column from the database and add the new field after that or otherwise add the 'lessor' field with a different field name. Also need to update the inverse field name in the 'contract_id' one2many field.


Hope it helps

Avatar
Zrušit
Autor Nejlepší odpověď

Please help me ~~~

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
bře 15
4413
0
bře 15
4689
0
zář 25
191
1
pro 24
4776
0
lis 24
1974