تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
7364 أدوات العرض

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
نوفمبر 23
1144
3
يونيو 21
12559
1
نوفمبر 15
5622
1
يناير 24
1309
2
يوليو 22
4598