forked from alaguraj/odoo-testing-addons
fix: website editor iframe blocked by dashboard controller, branding phone field, menu missing name
This commit is contained in:
parent
165e582927
commit
146495a2e6
@ -11,6 +11,20 @@
|
||||
'dine360_theme_chennora',
|
||||
'dine360_kds',
|
||||
'dine360_reservation',
|
||||
'dine360_uber',
|
||||
'dine360_recipe',
|
||||
'mail',
|
||||
'calendar',
|
||||
'contacts',
|
||||
'crm',
|
||||
'sale_management',
|
||||
'board',
|
||||
'point_of_sale',
|
||||
'account',
|
||||
'website',
|
||||
'purchase',
|
||||
'stock',
|
||||
'hr',
|
||||
],
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
'data': [
|
||||
|
||||
@ -15,50 +15,75 @@ 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
|
||||
# -----------------------------------------------------------
|
||||
fetch_dest = request.httprequest.headers.get('Sec-Fetch-Dest', '')
|
||||
is_iframe = fetch_dest == 'iframe'
|
||||
is_editor = kwargs.get('enable_editor') or request.params.get('enable_editor')
|
||||
|
||||
if is_iframe or is_editor:
|
||||
# Render the actual website homepage directly.
|
||||
# Do NOT call super().index() here — for logged-in admin users
|
||||
# the standard Website.index() may redirect to /web (backend),
|
||||
# which breaks the website editor iframe.
|
||||
return request.render('website.homepage')
|
||||
|
||||
# Not logged in → show the public website homepage
|
||||
if not request.session.uid:
|
||||
return request.render('website.homepage')
|
||||
|
||||
|
||||
# Remove sudo() to respect Odoo's standard menu group restrictions
|
||||
menus = request.env['ir.ui.menu'].search([
|
||||
('parent_id', '=', False)
|
||||
], order='sequence')
|
||||
|
||||
|
||||
# User role checks
|
||||
is_admin = request.env.user.has_group('base.group_system') or request.env.user.has_group('dine360_restaurant.group_restaurant_admin')
|
||||
is_kitchen = request.env.user.has_group('dine360_restaurant.group_restaurant_kitchen')
|
||||
try:
|
||||
is_admin = request.env.user.has_group('base.group_system') or \
|
||||
request.env.user.has_group('dine360_restaurant.group_restaurant_admin')
|
||||
is_kitchen = request.env.user.has_group('dine360_restaurant.group_restaurant_kitchen')
|
||||
except Exception:
|
||||
is_admin = request.env.user.has_group('base.group_system')
|
||||
is_kitchen = False
|
||||
|
||||
filtered_menus = []
|
||||
seen_names = set()
|
||||
for menu in menus:
|
||||
# 1. Hide "Apps" for non-admins (usually name is 'Apps' or xmlid has base.menu_management)
|
||||
# 1. Hide "Apps" for non-admins
|
||||
if (menu.name == 'Apps' or (menu.web_icon and menu.web_icon.startswith('base,'))) and not is_admin:
|
||||
continue
|
||||
|
||||
# 2. Hide "Kitchen (KDS)" for Waiters (only show for Kitchen Staff or Admin)
|
||||
|
||||
# 2. Hide "Kitchen (KDS)" for non-kitchen/non-admin users
|
||||
if 'Kitchen' in menu.name or 'KDS' in menu.name:
|
||||
if not (is_kitchen or is_admin):
|
||||
continue
|
||||
|
||||
# 3. De-duplicate by name to prevent double icons (like Kitchen showing twice)
|
||||
|
||||
# 3. De-duplicate by name
|
||||
if menu.name in seen_names:
|
||||
continue
|
||||
seen_names.add(menu.name)
|
||||
|
||||
|
||||
filtered_menus.append(menu)
|
||||
|
||||
|
||||
# Low Stock Alerts (Ingredients)
|
||||
low_stock_products = []
|
||||
try:
|
||||
# Try to get low stock products if the model and method exist
|
||||
ProductTemplate = request.env['product.template'].sudo()
|
||||
if hasattr(ProductTemplate, 'get_low_stock_products'):
|
||||
low_stock_products = ProductTemplate.get_low_stock_products(limit=5)
|
||||
except Exception:
|
||||
# Fallback if module is not yet fully loaded or method missing
|
||||
low_stock_products = []
|
||||
|
||||
|
||||
|
||||
return request.render('dine360_dashboard.image_home_template', {
|
||||
'menus': filtered_menus,
|
||||
'user_id': request.env.user,
|
||||
|
||||
@ -10,10 +10,8 @@
|
||||
<record id="base.main_company" model="res.company">
|
||||
<field name="phone">+1(647)856-2878</field>
|
||||
</record>
|
||||
<!-- Update the website phone as well, as it might be used in the header -->
|
||||
<record id="website.default_website" model="website">
|
||||
<field name="phone">+1(647)856-2878</field>
|
||||
</record>
|
||||
<!-- Note: 'phone' field is not available on the website model in Odoo 17.
|
||||
Phone/contact info should be set on res.company (line above) instead. -->
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
'category': 'Manufacturing',
|
||||
'summary': 'Manage recipes and automatic ingredient-level inventory deduction',
|
||||
'author': 'Dine360',
|
||||
'depends': ['point_of_sale', 'stock', 'dine360_restaurant'],
|
||||
'depends': ['point_of_sale', 'stock'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/recipe_views.xml',
|
||||
|
||||
@ -29,6 +29,9 @@
|
||||
|
||||
<!-- Update the menu item to use this action -->
|
||||
<record id="menu_restaurant_kds_orders" model="ir.ui.menu">
|
||||
<field name="name">Kitchen Display</field>
|
||||
<field name="parent_id" ref="point_of_sale.menu_point_root"/>
|
||||
<field name="action" ref="action_restaurant_kitchen_orders"/>
|
||||
<field name="sequence">30</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user