Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
7461 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhấ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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhấ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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 11 23
1256
3
thg 6 21
12715
1
thg 11 15
5722
1
thg 1 24
1411
2
thg 7 22
4738