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

I am trying it, after applying the breakpoint on onchange function, it is not coming on the function in debug mode, code is below

from odoo import api, models, fields

class Contacts(models.Model):
_inherit = 'res.partner'

is_patient = fields.Boolean('Patient')
is_doctor = fields.Boolean("Doctor", default=False)
is_nurse = fields.Boolean("Nurse", default=False)
is_institution = fields.Boolean("Institution", default=False)
is_person = fields.Boolean("Person", default=False)
is_insurance_company = fields.Boolean("Insurance Company", default=False)
is_pharmacy = fields.Boolean("Pharmacy", default=False)
num = fields.Integer("Integer")

@api.depends('is_patient')
def _onchange_insert_remove(self):
print("ddddddddd")
print("sssvsvsvs")

Please help me out in it

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

Thanks

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

If you are looking to trigger the function in the onchange of the field is_patient, use onchange decorator instead of depends.

Update the code as follows:

@api.onchange('is_patient')

def _onchange_is_patient(self):

.......


Fore more info, see:https://www.youtube.com/watch?v=zvV1Lt2bIcw&list=PLqRRLx0cl0hoZM788LH5M8q7KhiXPyuVU&index=27


Thanks & Regards

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
فبراير 16
6026
1
يناير 16
4208
1
نوفمبر 20
6033
0
أغسطس 19
4105
2
ديسمبر 23
2326