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

I have one model with 2 one2many relations (mat_gen and rh_gen). The first relation has a field named "qte", i want to update the second one when the "qte" changes with an onchange method.

@api.onchange('qte')

def onchange_qte(self):

mat = self.browse(self._origin.id)

if mat:

mo = self.env["plg.ressource.rh"].browse(mat.ch.id)

if mo:

temp = []

temp.append({ 'code': mo.code, 'designation': mo.designation, 'unite': mo.unite.id, 'qte': self.qte, 'aff_pr': self.aff_pr, 'prixu': mo.prixu, })

Here i've to access the parent model to update the second relation like self.parent.update({'rh_gen':temp}) but obviously the parent variable does not exist. How can i fix this?

Thanks in advance

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

Check this link

https://www.odoo.com/groups/technical-62/community-framework-23766083?mode=thread

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

hello..!
you can also update by calling write method
try this once self.parent.write({'rh_gen':temp}) 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 25
3930
3
ธ.ค. 22
11861
How to get current url from bowser? แก้ไขแล้ว
5
เม.ย. 24
42487
Add users to group through python code แก้ไขแล้ว
6
เม.ย. 24
39398
how to compute Len() of list python แก้ไขแล้ว
3
มี.ค. 24
10891