forked from alaguraj/odoo-testing-addons
Implement custom homepage dashboard, header styling, and role-based menu access with login redirection and title customization.
This commit is contained in:
parent
d48cb84a10
commit
8191f7d58c
Binary file not shown.
@ -18,16 +18,40 @@ class ImageHome(Website):
|
||||
if not request.session.uid:
|
||||
return request.render('website.homepage')
|
||||
|
||||
# Override root to show Dashboard for logged in users
|
||||
menus = request.env['ir.ui.menu'].sudo().search([
|
||||
# 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')
|
||||
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
if menu.name in seen_names:
|
||||
continue
|
||||
seen_names.add(menu.name)
|
||||
|
||||
filtered_menus.append(menu)
|
||||
|
||||
return request.render('dine360_dashboard.image_home_template', {
|
||||
'menus': menus,
|
||||
'menus': filtered_menus,
|
||||
'user_id': request.env.user
|
||||
})
|
||||
|
||||
|
||||
@http.route('/home', type='http', auth="public", website=True, sitemap=True)
|
||||
def website_home(self, **kw):
|
||||
# Explicit route for standard Website Homepage
|
||||
|
||||
@ -6,8 +6,8 @@ body .o_header_standard,
|
||||
body header.o_header_standard,
|
||||
body .navbar,
|
||||
body #o_main_nav {
|
||||
background-color: #171422 !important;
|
||||
background: #171422 !important;
|
||||
background-color: #111 !important;
|
||||
/* background: #171422 !important; */
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
|
||||
@ -32,12 +32,17 @@
|
||||
<span class="badge_dot"/>
|
||||
</a>
|
||||
|
||||
<a href="/web#action=base.action_res_config_general_settings" class="o_top_item" title="Settings">
|
||||
<i class="fa fa-sliders"/>
|
||||
</a>
|
||||
<!-- Only show Settings for Admins -->
|
||||
<t t-set="is_admin" t-value="user_id.has_group('base.group_system') or user_id.has_group('dine360_restaurant.group_restaurant_admin')"/>
|
||||
<t t-if="is_admin">
|
||||
<a href="/web#action=base.action_res_config_general_settings" class="o_top_item" title="Settings">
|
||||
<i class="fa fa-sliders"/>
|
||||
</a>
|
||||
</t>
|
||||
|
||||
<div class="o_bar_divider"></div>
|
||||
|
||||
|
||||
<div class="o_user_avatar_container">
|
||||
<a href="/web#action=base.action_res_users_my" class="o_user_avatar" style="display:flex; align-items:center; justify-content:center; text-decoration:none;">
|
||||
<t t-esc="user_id.name[0] if user_id else 'U'"/>
|
||||
|
||||
@ -4,15 +4,17 @@
|
||||
<title>Chennora</title>
|
||||
</xpath>
|
||||
<xpath expr="//body" position="inside">
|
||||
<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;
|
||||
border-radius: 50px; text-decoration: none; font-weight: bold;
|
||||
box-shadow: 0 4px 15px rgba(0,0,0,0.2); display: flex; align-items: center;
|
||||
gap: 8px; transition: all 0.3s ease; border: 2px solid #ffffffff !important; font-family: sans-serif;">
|
||||
<i class="fa fa-th-large" style="font-size: 18px;"></i>
|
||||
<span>Back to Dashboard</span>
|
||||
</a>
|
||||
<t t-if="not request.env.user._is_public()">
|
||||
<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;
|
||||
border-radius: 50px; text-decoration: none; font-weight: bold;
|
||||
box-shadow: 0 4px 15px rgba(0,0,0,0.2); display: flex; align-items: center;
|
||||
gap: 8px; transition: all 0.3s ease; border: 2px solid #ffffffff !important; font-family: sans-serif;">
|
||||
<i class="fa fa-th-large" style="font-size: 18px;"></i>
|
||||
<span>Back to Dashboard</span>
|
||||
</a>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<field name="groups_id" eval="[(4, ref('group_restaurant_manager')), (4, ref('group_restaurant_waiter')), (4, ref('group_restaurant_cashier'))]"/>
|
||||
</record>
|
||||
|
||||
<!-- Custom Kitchen Dashboard Menu -->
|
||||
<!-- Redundant: Consolidated into dine360_kds
|
||||
<menuitem id="menu_restaurant_kds_root"
|
||||
name="Kitchen (KDS)"
|
||||
web_icon="dine360_kds,static/description/icon.png"
|
||||
@ -20,4 +20,5 @@
|
||||
parent="menu_restaurant_kds_root"
|
||||
action="point_of_sale.action_pos_order_line_form"
|
||||
sequence="10"/>
|
||||
-->
|
||||
</odoo>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user