This question has been flagged
2 Replies
9981 Views

Hello,

I am trying to add the balance of customers to my pdf report but getting this error:


Odoo Server Error
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 333, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "", line 1, in template_mosadakat_3ameel_report_res_partner_897
  File "", line 2, in body_call_content_895
  File "", line 3, in foreach_894
  File "", line 4, in body_call_content_892
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 2034, in report_download
    response = self.report_routes(reportname, docids=docids, converter=converter, context=context)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 515, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1972, in report_routes
    pdf = report.with_context(context).render_qweb_pdf(docids, data=data)[0]
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 737, in render_qweb_pdf
    html = self.with_context(context).render_qweb_html(res_ids, data=data)[0]
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 777, in render_qweb_html
    return self.render_template(self.report_name, data), 'html'
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 548, in render_template
    return view_obj.render_template(template, values)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 1191, in render_template
    return self.browse(self.get_view_id(template)).render(values, engine)
  File "/usr/lib/python3/dist-packages/odoo/addons/web_editor/models/ir_ui_view.py", line 27, in render
    return super(IrUiView, self).render(values=values, engine=engine, minimal_qcontext=minimal_qcontext)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 1199, in render
    return self.env[engine].render(self.id, qcontext)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_qweb.py", line 58, in render
    result = super(IrQWeb, self).render(id_or_xml_id, values=values, **context)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 260, in render
    self.compile(template, options)(self, body.append, values or {})
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 340, in _compiled_fn
    raise QWebException("Error to render compiling AST", e, path, node and etree.tostring(node[0], encoding='unicode'), name)
odoo.addons.base.models.qweb.QWebException: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 333, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "", line 1, in template_mosadakat_3ameel_report_res_partner_897
  File "", line 2, in body_call_content_895
  File "", line 3, in foreach_894
  File "", line 4, in body_call_content_892
TypeError: 'NoneType' object is not subscriptable

Error to render compiling AST
TypeError: 'NoneType' object is not subscriptable
Template: mosadakat_3ameel.report_res_partner
Path: /t/t/t/t/div[1]/div/span[4]
Node: 
May anyone help in solving this error please.

Thanks in advance.
Waiting for an answer!.
Thank f
Avatar
Discard
Best Answer

Hello Asma
Base on your error comment.

mosadakat_3ameel is (Integer value)

Please finding your solution by trying these options.

Point- 1 This error occurs when you try to use the integer type value as an array. In simple terms, this error occurs when your program has a variable that is treated as an array by your function, but actually, that variable is an integer.

Point-2 Happens if you append a "None" Value to a list/

Thanks & Regards,

Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

Avatar
Discard
Best Answer

The error is self-explanatory. You are trying to subscript an object which you think is a list or dict, but actually is None (i.e: the object has no value). This means that you tried to do:

None[something]

Here you attempted to index an object that doesn't have that functionality. You might have noticed that the method sort() that only modify the list have no return value printed – they return the default None. This is a design principle for all mutable data structures in Python.

This 'NoneType' object is not subscriptable is the one thrown by python when you use the square bracket notation object[key] where an object doesn't define the __getitem__ method.




Avatar
Discard