This question has been flagged
2 Replies
16077 Views

Hi guys,

Can someone explain to me the source of this error?

Error:
Odoo Server Error

Traceback (most recent call last):
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\addons\base\models\ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\service\model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\http.py", line 347, in checked_call
result = self.endpoint(*a, **kw)
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\http.py", line 912, in __call__
return self.method(*args, **kw)
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\http.py", line 531, in response_wrap
response = f(*args, **kw)
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\addons\website_sale\controllers\backend.py", line 59, in fetch_dashboard_data
product_tmpl_id = request.env['product.template'].browse(product_line['product_tmpl_id'][0])
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Program Files\Odoo 14.0.20210531\server\odoo\http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
TypeError: 'bool' object is not subscriptable

Avatar
Discard
Best Answer

Hi,

This error occurs when data is False and when you are indexing it.

product_tmpl_id = request.env['product.template'].browse(product_line['product_tmpl_id'][0])

product_line['product_tmpl_id']  turns to be False which is the type Boolean ie  bool 

Here your indexing it with  [0] so does your error pops . Make sure get data in product_line['product_tmpl_id'] .

And try returning with product_line['product_tmpl_id'][0] or False

Thanks

Avatar
Discard
Best Answer

How to solve this problem? I got the same error. I dont know what I did wrong... I dont know what to do with the solution

Avatar
Discard