Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
2353 มุมมอง

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
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Please help me ~~~

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 15
4411
0
มี.ค. 15
4681
0
ก.ย. 25
150
1
ธ.ค. 24
4735
0
พ.ย. 24
1946