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.

0

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

By
Drees Far
on 8/21/15, 10:20 AM 646 views

Friends !!!

what does this error means please:

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

0

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 8/21/15, 11:02 AM

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

can i ask you an other question please

Drees Far
on 8/21/15, 11:04 AM

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

Pawan
on 8/21/15, 11:07 AM
0

Drees Far

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


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

did you get some thing??

Drees Far
on 8/21/15, 11:14 AM

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

Pawan
on 8/24/15, 2:59 AM

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

Drees Far
on 8/24/15, 5:26 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: 8/21/15, 10:20 AM
Seen: 646 times
Last updated: 8/21/15, 11:09 AM