forked from alaguraj/odoo-testing-addons
Introduce a custom dashboard with role-based menu filtering, low stock alerts, and branded web layout including title, favicon, and a dashboard return button.
This commit is contained in:
parent
efa9b1e14a
commit
75292e7b88
@ -15,29 +15,34 @@ from odoo.addons.website.controllers.main import Website
|
||||
class ImageHome(Website):
|
||||
@http.route('/', type='http', auth='public', website=True, sitemap=True)
|
||||
def index(self, **kwargs):
|
||||
# -----------------------------------------------------------
|
||||
# WEBSITE EDITOR FIX
|
||||
# When Odoo's Website editor loads the site, it opens it in an
|
||||
# iframe. We must NOT intercept that request with our backend
|
||||
# dashboard; instead let the real website homepage render so the
|
||||
# editor can attach to it.
|
||||
#
|
||||
# Detection methods (any one is enough):
|
||||
# 1. Sec-Fetch-Dest == 'iframe' → browser signals iframe load
|
||||
# 2. enable_editor param present → explicit editor activation
|
||||
# 3. ?debug= in query string → editor dev mode coming from /web
|
||||
# 2. enable_editor / edit param → explicit editor activation
|
||||
# 3. path param → Odoo redirection to a specific page
|
||||
# 4. Referer contains website/force → coming from editor switch
|
||||
# -----------------------------------------------------------
|
||||
fetch_dest = request.httprequest.headers.get('Sec-Fetch-Dest', '')
|
||||
referer = request.httprequest.headers.get('Referer', '')
|
||||
|
||||
is_iframe = fetch_dest == 'iframe'
|
||||
is_editor = kwargs.get('enable_editor') or request.params.get('enable_editor')
|
||||
|
||||
if is_iframe or is_editor:
|
||||
# Let the standard Website controller render the homepage
|
||||
is_editor_param = any([
|
||||
kwargs.get('enable_editor'),
|
||||
request.params.get('enable_editor'),
|
||||
kwargs.get('edit'),
|
||||
request.params.get('edit'),
|
||||
kwargs.get('path'),
|
||||
request.params.get('path')
|
||||
])
|
||||
is_from_editor = '/website/force' in referer or 'enable_editor' in referer or '/web' in referer
|
||||
|
||||
# In Odoo, when we click "Edit", it often redirects to /?path=...
|
||||
# If any editor signal is present, we must let the real website handle it.
|
||||
if is_iframe or is_editor_param or is_from_editor:
|
||||
return super(ImageHome, self).index(**kwargs)
|
||||
|
||||
# Not logged in → show the public website homepage
|
||||
# For public users (not logged in), always show the standard website homepage
|
||||
if not request.session.uid:
|
||||
return request.render('website.homepage')
|
||||
return super(ImageHome, self).index(**kwargs)
|
||||
|
||||
# Remove sudo() to respect Odoo's standard menu group restrictions
|
||||
menus = request.env['ir.ui.menu'].search([
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//body" position="inside">
|
||||
<t t-if="not request.env.user._is_public()">
|
||||
<t t-set="is_editor" t-value="request.params.get('enable_editor') or request.params.get('edit')"/>
|
||||
<t t-if="not request.env.user._is_public() and not is_editor">
|
||||
<a href="/" class="o_dashboard_return_btn d-print-none" title="Back to Dashboard"
|
||||
style="position: fixed; bottom: 20px; right: 20px; z-index: 99999;
|
||||
background-color: #d6111e; color: #ffff !important; padding: 12px 24px;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user