跳至内容
菜单
此问题已终结
2 回复
7489 查看

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.

形象
丢弃
相关帖文 回复 查看 活动
0
11月 23
1267
3
6月 21
12734
1
11月 15
5732
1
1月 24
1416
2
7月 22
4752