Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

why is boolean field not answering the onchange function?

By
Drees Far
on 11/27/15, 4:11 AM 547 views

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.

0
Julio Serna
On 11/27/15, 12:48 PM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/27/15, 4:11 AM
Seen: 547 times
Last updated: 11/28/15, 6:58 AM