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

Hello Community

i have a one Boolean field. and i have two mamy2one fields and this are depends on this Boolean field. i want to uncheck the checkbox(Boolean field) when I'm click on the default  form view save button. how to do this if anyone know this solution please let me know.

see my code

.py file

def create(self, cr, uid, vals, context=None):
    self.is_admin = False
    res_id = super(CrmLead, self).create(cr, uid, vals, context=context)
    return res_id

.xml file

we don't need to use this function in a xml file because create() is def​ault function.  

Thanks in Advanced

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

Hi, 


To uncheck the checked checkbox using default form save button in odoo, you need override write method as below: 


@api.multi

def write(self, vals):

vals['is_admin'] = False 

return super(CrmLead, self).write(vals) 


الصورة الرمزية
إهمال
الكاتب

Thanks Boss it's working perfectly for me.

but only put the @api.multi instead of @api.model

Thanks again :)

You are right @api.multi rather than @api.model. I already updated the answer. Please up vote for the answer.

الكاتب

yes u deserve it up vote

أفضل إجابة

Hello Kiran,

Try below code:-

@api.model

def create(self, vals):
    res_id = super(CrmLead, self).create(vals)

    res_id.is_admin = False                          
    return res_id


Hope it will works for you.

Thanks,

الصورة الرمزية
إهمال
الكاتب

Thank you so much sir

But it's works only for new created records not for existing records. i want to also apply same thing on existing record so what i do sir please let me know.

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أغسطس 20
5419
2
ديسمبر 18
27480
7
يوليو 18
13322
1
أغسطس 15
5535
0
مارس 15
5053