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

Error: [_.sprintf] expecting number but found array

By
Drees Far
on 11/30/15, 9:14 AM 503 views

Hello everybody!!!

Guys, a am using the onchange function for a float field.

Here is my code:

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

ret = []

print employee_id

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

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

res = obj.read(cr, uid, obj_ids, ['id', 'remaining_leaves','momo_matricule'])

for r in res :

print r['remaining_leaves']

inputs = {

'remaining_leave': r['remaining_leaves'],

}

ret += [inputs]

print ret

return ret

def on_change_employee_id(self, cr, uid, ids, employee_id, context=None):

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

}

}

return res

I have got this error: Error: [_.sprintf] expecting number but found array

Can any one help please.

Thanks a lot in advance

Best Regards.

1

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 11/30/15, 6:21 PM

Hi @Drees Far

For what you are doing this code will work:

def get_inputs(self, cr, uid,ids, employee_id, context=None):
obj = self.pool.get('hr.employee')
res = obj.browse(cr, uid, employee_id)
return res.remaining_leaves

def on_change_employee_id(self, cr, uid, ids, employee_id, context=None):
res = {
'value':{
'remaining_leave': self.get_inputs(cr, uid, ids, employee_id, context=context),
}
}
return res

Thanks a lot my friend. This works perfectly but plz i would like to know the reason to not have the same mistake in the futur :)

Drees Far
on 12/1/15, 4:18 AM

Your function get_inputs was returning a list of dicts instead of a single value for the only one employee you passed. Also no search is needed to find the employee id because you already have it.

Axel Mendoza
on 12/1/15, 9:15 AM

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

2 follower(s)

Stats

Asked: 11/30/15, 9:14 AM
Seen: 503 times
Last updated: 12/3/15, 12:37 PM