콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
6970 화면

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
8월 20
5393
2
12월 18
27441
7
7월 18
13288
1
8월 15
5517
0
3월 15
5041