Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
7456 Weergaven

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

Avatar
Annuleer
Beste antwoord

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
Annuleer
Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
nov. 23
1254
3
jun. 21
12708
1
nov. 15
5720
1
jan. 24
1407
2
jul. 22
4734