Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
7573 Tampilan

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

Avatar
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
0
Nov 23
1363
3
Jun 21
12882
1
Nov 15
5845
1
Jan 24
1502
2
Jul 22
4865