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:
|
if not request.session.uid:
|
||||||
return request.render('website.homepage')
|
return request.render('website.homepage')
|
||||||
|
|
||||||
# Override root to show Dashboard for logged in users
|
# Remove sudo() to respect Odoo's standard menu group restrictions
|
||||||
menus = request.env['ir.ui.menu'].sudo().search([
|
menus = request.env['ir.ui.menu'].search([
|
||||||
('parent_id', '=', False)
|
('parent_id', '=', False)
|
||||||
], order='sequence')
|
], 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', {
|
return request.render('dine360_dashboard.image_home_template', {
|
||||||
'menus': menus,
|
'menus': filtered_menus,
|
||||||
'user_id': request.env.user
|
'user_id': request.env.user
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@http.route('/home', type='http', auth="public", website=True, sitemap=True)
|
@http.route('/home', type='http', auth="public", website=True, sitemap=True)
|
||||||
def website_home(self, **kw):
|
def website_home(self, **kw):
|
||||||
# Explicit route for standard Website Homepage
|
# Explicit route for standard Website Homepage
|
||||||
|
|||||||
@ -6,8 +6,8 @@ body .o_header_standard,
|
|||||||
body header.o_header_standard,
|
body header.o_header_standard,
|
||||||
body .navbar,
|
body .navbar,
|
||||||
body #o_main_nav {
|
body #o_main_nav {
|
||||||
background-color: #171422 !important;
|
background-color: #111 !important;
|
||||||
background: #171422 !important;
|
/* background: #171422 !important; */
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,12 +32,17 @@
|
|||||||
<span class="badge_dot"/>
|
<span class="badge_dot"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="/web#action=base.action_res_config_general_settings" class="o_top_item" title="Settings">
|
<!-- Only show Settings for Admins -->
|
||||||
<i class="fa fa-sliders"/>
|
<t t-set="is_admin" t-value="user_id.has_group('base.group_system') or user_id.has_group('dine360_restaurant.group_restaurant_admin')"/>
|
||||||
</a>
|
<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_bar_divider"></div>
|
||||||
|
|
||||||
|
|
||||||
<div class="o_user_avatar_container">
|
<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;">
|
<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'"/>
|
<t t-esc="user_id.name[0] if user_id else 'U'"/>
|
||||||
|
|||||||
@ -4,15 +4,17 @@
|
|||||||
<title>Chennora</title>
|
<title>Chennora</title>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//body" position="inside">
|
<xpath expr="//body" position="inside">
|
||||||
<a href="/" class="o_dashboard_return_btn d-print-none" title="Back to Dashboard"
|
<t t-if="not request.env.user._is_public()">
|
||||||
style="position: fixed; bottom: 20px; right: 20px; z-index: 99999;
|
<a href="/" class="o_dashboard_return_btn d-print-none" title="Back to Dashboard"
|
||||||
background-color: #d6111e; color: #ffff !important; padding: 12px 24px;
|
style="position: fixed; bottom: 20px; right: 20px; z-index: 99999;
|
||||||
border-radius: 50px; text-decoration: none; font-weight: bold;
|
background-color: #d6111e; color: #ffff !important; padding: 12px 24px;
|
||||||
box-shadow: 0 4px 15px rgba(0,0,0,0.2); display: flex; align-items: center;
|
border-radius: 50px; text-decoration: none; font-weight: bold;
|
||||||
gap: 8px; transition: all 0.3s ease; border: 2px solid #ffffffff !important; font-family: sans-serif;">
|
box-shadow: 0 4px 15px rgba(0,0,0,0.2); display: flex; align-items: center;
|
||||||
<i class="fa fa-th-large" style="font-size: 18px;"></i>
|
gap: 8px; transition: all 0.3s ease; border: 2px solid #ffffffff !important; font-family: sans-serif;">
|
||||||
<span>Back to Dashboard</span>
|
<i class="fa fa-th-large" style="font-size: 18px;"></i>
|
||||||
</a>
|
<span>Back to Dashboard</span>
|
||||||
|
</a>
|
||||||
|
</t>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
</odoo>
|
</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'))]"/>
|
<field name="groups_id" eval="[(4, ref('group_restaurant_manager')), (4, ref('group_restaurant_waiter')), (4, ref('group_restaurant_cashier'))]"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Custom Kitchen Dashboard Menu -->
|
<!-- Redundant: Consolidated into dine360_kds
|
||||||
<menuitem id="menu_restaurant_kds_root"
|
<menuitem id="menu_restaurant_kds_root"
|
||||||
name="Kitchen (KDS)"
|
name="Kitchen (KDS)"
|
||||||
web_icon="dine360_kds,static/description/icon.png"
|
web_icon="dine360_kds,static/description/icon.png"
|
||||||
@ -20,4 +20,5 @@
|
|||||||
parent="menu_restaurant_kds_root"
|
parent="menu_restaurant_kds_root"
|
||||||
action="point_of_sale.action_pos_order_line_form"
|
action="point_of_sale.action_pos_order_line_form"
|
||||||
sequence="10"/>
|
sequence="10"/>
|
||||||
|
-->
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user