In my server Log-file on Odoo.sh (odoo-v13), i often see the following error without understanding exactly what is the reason of that: odoo.exceptions.CacheMiss: ('x_eventcoursetype(6,).x_name', None)
I can see that this error is related to my custom model x_eventcoursetype, that is a sub-category of official model "event.event" (bind to it via M2O).
This model is then used on my website inside the top-bar menu (xml template inheriting from the standard view: website_event.index_topbar) to filter the event by this sub-category:
<?xml version="1.0"?>
<data inherit_id="website_event.index_topbar" active="True" customize_show="True" name="Filter by xEvTyp">
<xpath expr="//ul[hasclass('o_wevent_index_topbar_filters')]" position="inside">
<li class="nav-item dropdown mr-2 my-1 my-lg-0">
<a href="#" role="button" class="btn dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-folder-open"/>
<t t-if="current_xevtyp" t-esc="current_xevtyp.x_name"/>
<t t-else="">All Event Types</t>
</a>
<div class="dropdown-menu">
<t t-foreach="xevtyps" t-as="xevtyp">
<t t-if="xevtyp['evcoursetype_id']">
<a t-att-href="keep('/event', xevtyp=xevtyp['evcoursetype_id'][0])" t-attf-class="dropdown-item d-flex align-items-center justify-content-between #{searches.get('xevtyp') == str(xevtyp['evcoursetype_id'] and xevtyp['evcoursetype_id'][0]) and 'active'}">
<t t-if="xevtyp['evcoursetype_id'][1] == 'all' ">
All types
</t>
<t t-else="" t-esc="xevtyp['evcoursetype_id'][1]"/>
<span t-esc="xevtyp['evcoursetype_id_count']" class="badge badge-pill badge-primary ml-3"/>
</a>
</t>
</t>
</div>
</li>
</xpath>
</data>
The names of model-records are perfectly displayed in the website top-bar (as filter) and the choice does filter the event accordingly to their x_eventcoursetype value, without displaying any Error on the Front Office.
But the Error is reported in the log file: TRACEBACK:
2023-09-08 13:41:52,801 4 ERROR myodoo-oerp-master-1178741 odoo.addons.http_routing.models.ir_http: 500 Internal Server Error:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/api.py", line 748, in get
value = self._data[field][record._ids[0]]
KeyError: 6
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/fields.py", line 1059, in __get__
value = env.cache.get(record, self)
File "/home/odoo/src/odoo/odoo/api.py", line 754, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('x_eventcoursetype(6,).x_name', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/addons/base/models/qweb.py", line 334, in _compiled_fn
return compiled(self, append, new, options, log)
File "<template>", line 1, in template_website_event_index_topbar_12493
File "/home/odoo/src/odoo/odoo/fields.py", line 1070, in __get__
raise MissingError("\n".join([
odoo.exceptions.MissingError: ('Enregistrement inexistant ou détruit.\n(Enregistrement: x_eventcoursetype(6,), Utilisateur: 4)', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 234, in _dispatch
result = request.dispatch()
File "/home/odoo/src/odoo/odoo/http.py", line 805, in dispatch
r = self._call_function(**self.params)
File "/home/odoo/src/odoo/odoo/http.py", line 350, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/http.py", line 342, in checked_call
result.flatten()
File "/home/odoo/src/odoo/odoo/http.py", line 1214, in flatten
self.response.append(self.render())
File "/home/odoo/src/odoo/odoo/http.py", line 1207, in render
return env["ir.ui.view"].render_template(self.template, self.qcontext)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 1201, in render_template
return self.browse(self.get_view_id(template)).render(values, engine)
File "/home/odoo/src/odoo/addons/website/models/ir_ui_view.py", line 347, in render
return super(View, self).render(values, engine=engine, minimal_qcontext=minimal_qcontext)
File "/home/odoo/src/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 "/home/odoo/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 1209, in render
return self.env[engine].render(self.id, qcontext)
File "/home/odoo/src/enterprise/web_studio/models/ir_qweb.py", line 43, in render
return super(IrQWeb, self).render(template, values=values, **options)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_qweb.py", line 58, in render
result = super(IrQWeb, self).render(id_or_xml_id, values=values, **context)
File "/home/odoo/src/odoo/odoo/addons/base/models/qweb.py", line 261, in render
self.compile(template, options)(self, body.append, values or {})
File "/home/odoo/src/odoo/odoo/addons/base/models/qweb.py", line 336, in _compiled_fn
raise e
File "/home/odoo/src/odoo/odoo/addons/base/models/qweb.py", line 334, in _compiled_fn
return compiled(self, append, new, options, log)
File "<template>", line 1, in template_website_event_index_12472
File "<template>", line 2, in body_call_content_12470
File "/home/odoo/src/odoo/odoo/addons/base/models/qweb.py", line 341, 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: ('Enregistrement inexistant ou détruit.\n(Enregistrement: x_eventcoursetype(6,), Utilisateur: 4)', None)
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/api.py", line 748, in get
value = self._data[field][record._ids[0]]
KeyError: 6
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/fields.py", line 1059, in __get__
value = env.cache.get(record, self)
File "/home/odoo/src/odoo/odoo/api.py", line 754, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('x_eventcoursetype(6,).x_name', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/addons/base/models/qweb.py", line 334, in _compiled_fn
return compiled(self, append, new, options, log)
File "<template>", line 1, in template_website_event_index_topbar_12493
File "/home/odoo/src/odoo/odoo/fields.py", line 1070, in __get__
raise MissingError("\n".join([
odoo.exceptions.MissingError: ('Enregistrement inexistant ou détruit.\n(Enregistrement: x_eventcoursetype(6,), Utilisateur: 4)', None)
Error to render compiling AST
MissingError: ('Enregistrement inexistant ou détruit.\n(Enregistrement: x_eventcoursetype(6,), Utilisateur: 4)', None)
Template: website_event.index_topbar
Path: /t/t/nav/div/ul/li[3]/a/t[1]
Node: <t t-if="current_xevtyp" t-esc="current_xevtyp.x_name"/>
Any clue is welcome !

ERROR CAUSE: in my controller (main.py) : .browse(id) provide a record even for an unexisting ID !!! in:
I SOLVED IT BY REPLACING IT BY: