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

Hi,

in my form i added two fields for attachment work but this code could not save two different attachement in each field,  it just save automatically  the same attachement in both of them. how plz can i resolve this.

this my code in .py : 

identity_card = fields.Many2many('ir.attachment', string="Identity card")
Contract = fields.Many2many('ir.attachment', string="Contract")
in xml :
<field name="identity_card" widget="many2many_binary"/>
<field name="Contract" widget="many2many_binary"/>

Screenshot : 
Regards



อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Medmars,

Would this solve your problem?

Regards,

-make

identity_card= fields.Many2many(comodel_name="ir.attachment", 
                                relation="m2m_ir_identity_card_rel",
                                column1="m2m_id",
                                column2="attachment_id",
                                string="Identity Card")
contract = fields.Many2many(comodel_name="ir.attachment",
                                relation="m2m_ir_contract_rel".
                                column1="m2m_id",
                                column2="attachment_id",
                                string="Contract")
<field name="identity_card" widget="many2many_binary"/>
<field name="contract" widget="many2many_binary"/>
อวตาร
ละทิ้ง
ผู้เขียน

Perfect answer ! Thanks

This man deserves Nobel prize :)

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 20
10816
2
ก.ค. 25
4618
2
ธ.ค. 24
7770
How to ORDER BY? [Odoo 10] แก้ไขแล้ว
2
พ.ย. 24
28533
2
พ.ค. 24
7478