Skip to Content
Menu
This question has been flagged
4 Replies
4711 Views

Friends !!!

what does this error means please:

"'NoneType' object has no attribute 'browse'",

Avatar
Discard
Best Answer

Hi Drees,

'NoneType' object has no attribute 'browse' means that you are trying to call 'browse' method on object which has nothing..... means 'None' type of object, you can check this by printing "type(your_object)" in you python code it wil give you 'None'.

Avatar
Discard
Author

can i ask you an other question please

Sure Drees, i will surely try to help you....

Author Best Answer


i am working with mako extension and call a function defined in my python file:

def __init__(self, cr, uid, name, context):

super(journal_paie, self).__init__(cr, uid, name, context)

print ('test test')

self.localcontext.update({

'get_lines': self.get_lines,

'cr':cr,

'uid':1,

'ctxt':context,

})

def get_lines(self, cr,uid, context=None):

ret = []

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

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

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

for r in res :

if r['name_related'] != 'Administrator' :

line_data = dict()

line_data['name']= r['name_related']

print r['name_related']

ret.append(line_data)

return ret

like this:

% for i in get_lines():

<tr style='height:20.65pt'>

<td width=31.9 style='width:31.9pt;border:none;border-bottom:solid windowtext 1.0pt;

background:#FCE4D6;padding:0cm 3.5pt 0cm 3.5pt;height:14.65pt'>

<p class=MsoNormal align=center style='margin-bottom:0cm;margin-bottom:.0001pt;

text-align:center;line-height:normal'><b><span style='font-size:8.0pt;

font-family:"Arial","sans-serif";color:black'>Nom Employé</span></b></p>

</td>

<td width=31.9 style='width:31.9pt;border:none;border-bottom:solid windowtext 1.0pt;

background:#FCE4D6;padding:0cm 3.5pt 0cm 3.5pt;height:14.65pt'>

<p class=MsoNormal align=center style='margin-bottom:0cm;margin-bottom:.0001pt;

text-align:center;line-height:normal'><b><span style='font-size:8.0pt;

font-family:"Arial","sans-serif";color:black'> ${i}</span></b></p>

</td>

</tr>

%endfor

and i get this error:

% for i in get_lines():

TypeError: 'Undefined' object is not callable

Traceback (most recent call last):

File "/opt/openerp/v7/server/openerp/netsvc.py", line 296, in dispatch_rpc

result = ExportService.getService(service_name).dispatch(method, params)

File "/opt/openerp/v7/server/openerp/service/web_services.py", line 654, in dispatch

res = fn(db, uid, *params)

File "/opt/openerp/v7/server/openerp/service/web_services.py", line 760, in exp_report_get

return self._check_report(report_id)

File "/opt/openerp/v7/server/openerp/service/web_services.py", line 738, in _check_report

netsvc.abort_response(exc, exc.message, 'warning', exc.traceback)

File "/opt/openerp/v7/server/openerp/netsvc.py", line 71, in abort_response

raise openerp.osv.osv.except_osv(description, details)

except_osv: (u'Rendu webkit !', u'\n\nTraceback (most recent call last):\n File "/opt/openerp/v7/addons/report_webkit/webkit_report.py", line 265, in create_single_pdf\n **parser_instance.localcontext)\n File "/usr/lib/python2.7/dist-packages/mako/template.py", line 443, in render\n return runtime._render(self, self.callable_, args, data)\n File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 803, in _render\n **_kwargs_for_callable(callable_, data))\n File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 835, in _render_context\n _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)\n File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 860, in _exec_template\n callable_(context, *args, **kwargs)\n File "memory:0x7fe8c06d1e10", line 83, in render_body\n % for i in get_lines():\nTypeError: \'Undefined\' object is not callable\n')

Avatar
Discard
Author

did you get some thing??

Dress, inspite of calling a def function from another file, you can simply define it as inline in mako file only under <%def> tag like:
<%def name="my_function(x)"> this is function ${x} <%def>
and call it as:
${my_function(variable_in_local_scope)}
hope it helps u

Author

sorry but you cant use self, cr or uid if you do like this :/ I have tried it it doesnt work unfortunately

Related Posts Replies Views Activity
2
May 22
31162
0
Mar 19
2686
0
Jan 19
3633
4
Feb 24
10712
0
Jan 18
2778