Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
7470 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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


Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
lis 23
1258
3
cze 21
12717
1
lis 15
5726
1
sty 24
1412
2
lip 22
4741