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

Hello friends!!!

I am using an onchange function to modify a boolean field.

here is the code:

Python:

def on_change_valid_id(self, cr, uid, ids,is_valid, context=None):

res = {'value':{'is_valid': self.get_inputs(cr, uid, ids, is_valid, context=context),

}

}

return res

def get_inputs(self, cr, uid,ids, is_valid, context=None):

ret = []

present = datetime.now()

a = str(present.year)+'-'+str(present.month)+'-'+str(present.day)

for obj in self.browse(cr, uid, ids, context=context):

matricule = obj.employee_id.id

obj = self.pool.get('hr.contract')

obj_ids = obj.search(cr, uid, [('employee_id', '=', matricule)])

res = obj.read(cr, uid, obj_ids, ['id', 'employee_id', 'date_end'], context)

for r in res:

b = str(r['date_end'])

compare = a > b

print compare

if compare == False:

inputs = {

'is_valid': True,

}

ret += [inputs]

else:

inputs = {

'is_valid': True,

}

ret += [inputs]

print ret

return ret

Can any one help please.

Best Regards.

아바타
취소
베스트 답변

Hello Drees,

I can see that get_inputs function return [{'is_valid': True}] and you are call in onchange that function, and your onchange is return something like this,

{'value':{'is_valid': [{'is_valid': True}] ,

}

The return must be something like this,

{'value':{'is_valid': True,

}

also, you must check that field is not like readonly

아바타
취소
관련 게시물 답글 화면 활동
1
2월 16
6624
0
11월 23
1246
2
12월 22
7440
2
5월 22
33860
0
3월 19
4019