Hello odoo-ers all around the world,
My question is, what is the reason behind the error as follows:
2024-08-05 09:30:11 Traceback (most recent call last):
2024-08-05 09:30:11 File "/usr/lib/python3/dist-packages/odoo/tools/cache.py", line 99, in lookup
2024-08-05 09:30:11 r = d[key]
2024-08-05 09:30:11 File "", line 2, in __getitem__
2024-08-05 09:30:11 File "/usr/lib/python3/dist-packages/odoo/tools/func.py", line 87, in locked
2024-08-05 09:30:11 return func(inst, *args, **kwargs)
2024-08-05 09:30:11 File "/usr/lib/python3/dist-packages/odoo/tools/lru.py", line 34, in __getitem__
2024-08-05 09:30:11 a = self.d[obj]
2024-08-05 09:30:11 KeyError: ('purchase.order', , (970, 'tree', None, 'en_US', uom.uom(3,)))
I got this in log when I am using def _get_view(...) overloading method in my inherited Purchase Order model,
here's my complete '_get_view' code:
@api.model def _get_view(self, view_id=None, view_type='form', **options): arch, view = super()._get_view(view_id, view_type, **options)
# Simulate context for testing purposes simulated_context = { 'active_model': self._name, # Replace with actual model name 'active_id': self._origin.id, # Replace with actual record ID # Add other missing context keys as needed } context = dict(self._context, **simulated_context) _logger.exception("GET VIEW: CONTEXT ??? >>>>> %s", (context))
# Rest of your code # context = self._context active_id = self.env.context.get('active_id')
# _logger.exception("ACTIVE ID: ??? >>>>> %s", (self._origin.id if not active_id else active_id))
if view_type == 'form' and context: # _logger.exception( # "VIEW TYPE and CONTEXT and OPTIONS: ??? >>>>> %s - %s - %s", # (view_type, context, options) # )
if context.get('params'): if context['params'].get('id'): params_id = context['params']['id'] purchase_id = self.env[self._name].browse(params_id)
for node in arch.xpath("//button[@name='button_approval']"): # _logger.exception("ARCH.XPATH: ??? >>>>> %s %s", (arch, view)) node.attrib['string'] = fields.Datetime.now().strftime("%d-%b-%y %H:%M:%S")
return arch, view
what did I do wrong? furthermore, how to solve it?
Thanks in advance