İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
7949 Görünümler

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

Avatar
Vazgeç
En İyi Yanıt

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


Avatar
Vazgeç
En İyi Yanıt

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.

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Kas 23
1651
3
Haz 21
13367
1
Kas 15
6307
1
Oca 24
1825
2
Tem 22
5379