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

How to add onchange event with Save, Create or Edite Buttons (these are default button within a form)?

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

You can try to override the create/write methods and call the onchange methods.

Ex:

@api.model
def create(self, vals):
res = super(...).create(vals)
res.onchange_product_id()
return res


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

You cannot you can only just override the create/write methods like Sudhir Arya suggested. 

If you want to do operations before the data is saved you have to do before the super(<your_class_name>).create(vals) method. Then your data is in the vals dict. If you need the record to be already save do it after. Then your data is in the res object.

Oh and you do not need the onchange decorator on the method you wanna execute.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ย. 23
1243
3
มิ.ย. 21
12684
1
พ.ย. 15
5708
1
ม.ค. 24
1394
2
ก.ค. 22
4717