Odoo Help


AttributeError: 'int' object has no attribute 'get'

Vale Trood
on 11/16/15, 5:32 AM 1,583 views

Good Morning everybody;

In fact, i am creating a new report in OpenERP.

So, i call a function in the file.py of the report:

def get_details(self, year, context=None):


if not context:

context = None

ret = []

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

obj_ids = obj.search(self.cr, self.uid, [('name_related','!=', '')])

print ('testing me')

 ####################"the error is in this line##################

res = obj.read(self.cr, self.uid, obj_ids, ['id', 'name_related','momo_matricule','birthday'], context)

date_jour = time.strftime('%y/%m/%d',time.localtime())

date_jour_annee = time.strftime('%Y',time.localtime())

for r in res :

objs = {}

birthday = r['birthday']

objs['nom_employe'] = r['name_related']

a = int(birthday[:4])

b = date_jour_annee

age = int(b) - int(a)

obj3 = self.pool.get('hr.holidays')

key = r['id']

obj_ids3 = obj3.search(self.cr, self.uid, [('employee_id','=',key),('state','=','validate')])

res3 = obj3.read(self.cr, self.uid, obj_ids3, ['number_of_days', 'date_from','resumption_date','employee_id'], context)

# print res3

if age < 35:

k = []

for var in res3:


playlist = {}

playlist["employee_id"] = var['employee_id']

playlist["holidays"] = []



print playlist

row_json = json.dumps(k)

print row_json

objs['number_days'] = k


for var in res3:

objs['number_days_jeune'] = var['number_of_days']

objs['date_from_jeune'] = var['date_from']

objs['resumption_date_jeune'] = var['resumption_date']

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

obj_ids2 = obj2.search(self.cr, self.uid, [('employee_id','=',key)])

res2 = obj2.read(self.cr, self.uid, obj_ids2, ['id', 'date_start','trial_date_start'], context)

for t in res2 :

if t['trial_date_start'] == False:

objs['date_to'] = t['date_start']


objs['date_to'] = t['trial_date_start']

objs['date_to'] = t['date_start']

objs['year'] = year


return res_list

when i click on PRINT, i got this error:

2015-11-16 10:24:15,688 5820 ERROR openerp openerp.addons.report_webkit.webkit_report:

Traceback (most recent call last):

File "/opt/openerp/v7/addons/report_webkit/webkit_report.py", line 274, in create_single_pdf


File "/usr/lib/python2.7/dist-packages/mako/template.py", line 443, in render

return runtime._render(self, self.callable_, args, data)

File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 803, in _render

**_kwargs_for_callable(callable_, data))

File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 835, in _render_context

_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)

File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 860, in _exec_template

callable_(context, *args, **kwargs)

File "memory:0x7fb7d6412650", line 111, in render_body

%for item in get_details(cr,uid):

File "/opt/openerp/v7/addons/seetek_payroll/report/report_leaves.py", line 62, in get_details

test = obj.read(self.cr, self.uid, obj_ids, ['id', 'name_related','momo_matricule','birthday'], context)

File "/opt/openerp/v7/server/openerp/osv/orm.py", line 3679, in read

result = self._read_flat(cr, user, select, fields, context, load)

File "/opt/openerp/v7/server/openerp/osv/orm.py", line 3740, in _read_flat

if context.get('lang'):

AttributeError: 'int' object has no attribute 'get'

Is here any suggestion to help.

Thanks a lot in advance.



Vale Trood

--Vale Trood--

| 5 2 7
Tunis, France
--Vale Trood--

Vale Trood
On 11/16/15, 8:42 AM


I have found the answer to my question.

Here is the answer:

res = obj.read(self.cr, self.uid, obj_ids, ['id', 'name_related','momo_matricule','birthday'], context)

I have to delete the context as a parameter to read.

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

Best Regards.

Bipin rathod
On 11/16/15, 6:58 AM


obj_ids = obj.search(self.cr, self.uid, [('name_related','!=', '')])

problem here, when you search you will not get any obj_ids here, please use proper domain and use it again.

Hope after changing the domain, it will be work.

friend, i have changed that but nothing happened :/

Vale Trood
on 11/16/15, 8:02 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.


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

1 follower(s)


Asked: 11/16/15, 5:32 AM
Seen: 1583 times
Last updated: 11/21/15, 6:08 AM