Hi,
I'm in the process of upgrading Odoo from v16 to v18.
I have already fixed many errors and updated code that was causing conflicts.
At the moment, I can navigate through all applications without issues except for the Website, which always returns the following error:
Error while render the template
UnboundLocalError: cannot access local variable 'template' where it is not associated with a value
Template: website.layout
Path: /t/html/body/div[2]/main/div[1]
Node: <div t-if="o_portal_fullwidth_alert" class="container mt-3"/>
This happens on every possible page of the website.
Over time, I have made many modifications to views, so I’m concerned I might have broken something.
If that’s the case, could you advise me on how I can debug or fix this? I’m not sure where to start.
While inspecting the views, I found the following block:
<xpath expr="//div[@id='wrapwrap']/main/t[@t-out='0']" position="before">
<div t-if="o_portal_fullwidth_alert or False" class="container mt-3">
<div class="alert alert-info alert-dismissible fade show d-print-none css_editable_mode_hidden">
<t t-out="o_portal_fullwidth_alert"/>
</div>
</div>
</xpath>
It seems this block might be related to the div with id="wrapwrap".
I suspect that the error could be triggered by this piece of code, but I’m not sure why it causes the UnboundLocalError.
Extra information:
- When creating a brand new website (as expected), no error occurs.
Attempts to fix:
- Commented out the problematic block.
- Reviewed inherited views in website.layout for possible conflicts (I may still missing something).
- Verified that a brand new website (with no custom views) works fine, confirming that the problem is specific to the upgraded/customized site.