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

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

By
Drees Far
on 11/16/15, 5:32 AM 628 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):

res_list=[]

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:

k.append(var['number_of_days'])

playlist = {}

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

playlist["holidays"] = []

playlist["holidays"].append(var['number_of_days'])

print('***************************************************************')

print playlist

row_json = json.dumps(k)

print row_json

objs['number_days'] = k

else:

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']

else:

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

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

objs['year'] = year

res_list.append(objs)

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

**self.parser_instance.localcontext)

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.

Regards.

1

Drees Far

--Drees Far--
1130
| 5 2 6
Tunis, Tunisia
--Drees Far--
Drees Far
On 11/16/15, 8:42 AM

Hello!!!!

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.

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

Hello,


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 :/

Drees Far
on 11/16/15, 8:02 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

1 follower(s)

Stats

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