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

So I have two categories for the maintenance equipments:​

  • Laptop

  • Software (Office etc.)

I added many2many field inside equipments model that allows me to pick software installed on a particular device:

class custom_category_fields(models.Model):
_inherit = 'maintenance.equipment'

soft_ids = fields.Many2many(comodel_name='maintenance.equipment', relation='custom_maintenance_equipment_soft_eq_rel', column1="eq_id", column2="soft_id", string='Software')


But I would like to also have reverse connection - so I could check from the software point of view where it is installed.

I'm having trouble figuring out how to define this additional field. I have something like this:

    device_ids = fields.Many2many(comodel_name='maintenance.equipment', relation='custom_maintenance_equipment_soft_eq_rel', column1="eq_id", column2="soft_id", string='Devices')


But obviously it does not contain information about devices with that software yet. How do I do this so both devices and software would hold information about the connection?

I thought about extending create and write method to fill in the values but I don't know python syntax to archive this.

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

Ok, I got this. I only needed to change order of 

column1="eq_id", column2="soft_id"

to

column1="soft_id", column2="eq_id"
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ย. 22
5190
1
ก.ย. 21
2461
0
ส.ค. 21
95
0
ก.ค. 21
172
0
พ.ค. 21
1239