Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5337 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Check this link

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 25
3931
3
thg 12 22
11868
5
thg 4 24
42494
6
thg 4 24
39402
3
thg 3 24
10894