Odoo Help

1

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

By
Drees Far
on 11/30/15, 9:14 AM 796 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--
11108
| 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

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

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