[REF] website: merge Website and Website Admin menu items
This commit merge the two website menu items in order to ease user flow inside Odoo. When clicking on the Website item a server action is called that decides to redirect the user either to the dashboard if the user is an admin or a website publisher, either to the website for other people. Overriding this method allows to define a specific behavior. Future commit will also redirect sales people to the website dashboard. Dashboard itself is customized to add a header used to display a website button. It will be used in future commits to add other new stuff to the dashboard.
This commit is contained in:
committed by
Thibault Delavallée
parent
47b532638e
commit
79597a2b84
@@ -17,18 +17,16 @@ Odoo Website CMS
|
||||
'installable': True,
|
||||
'data': [
|
||||
'data/website_data.xml',
|
||||
'data/web_planner_data.xml',
|
||||
'security/website_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
|
||||
'views/website_templates.xml',
|
||||
'views/website_navbar_templates.xml',
|
||||
'views/snippets.xml',
|
||||
'views/website_views.xml',
|
||||
'views/res_config_views.xml',
|
||||
'views/ir_actions_views.xml',
|
||||
|
||||
'wizard/base_language_install_views.xml',
|
||||
'data/web_planner_data.xml',
|
||||
],
|
||||
'demo': [
|
||||
'data/website_demo.xml',
|
||||
|
||||
@@ -709,7 +709,7 @@
|
||||
<record id="planner_website" model="web.planner">
|
||||
<field name="name">Website Planner</field>
|
||||
<field name="view_id" ref="website_planner"/>
|
||||
<field name="menu_id" ref="website.menu_website"/>
|
||||
<field name="menu_id" ref="website.menu_website_configuration"/>
|
||||
<field name="planner_application">planner_website</field>
|
||||
<field name="tooltip_planner"><![CDATA[
|
||||
Plan your website strategy, design your pages, sell your products and grow your online business!
|
||||
|
||||
@@ -65,13 +65,6 @@
|
||||
<field name="target">self</field>
|
||||
</record>
|
||||
|
||||
<record id="menu_website" model="ir.ui.menu">
|
||||
<field name="name">Website</field>
|
||||
<field name="sequence" eval="200"/>
|
||||
<field name="web_icon">website,static/description/icon.png</field>
|
||||
<field name="action" ref="action_website"/>
|
||||
</record>
|
||||
|
||||
<record id="base.open_menu" model="ir.actions.todo">
|
||||
<field name="action_id" ref="action_website"/>
|
||||
<field name="state">open</field>
|
||||
|
||||
@@ -601,6 +601,12 @@ class Website(models.Model):
|
||||
return urlparse.urljoin(cdn_url, uri)
|
||||
return uri
|
||||
|
||||
@api.model
|
||||
def action_dashboard_redirect(self):
|
||||
if self.env.user.has_group('base.group_system') or self.env.user.has_group('website.group_website_designer'):
|
||||
return self.env.ref('website.backend_dashboard').read()[0]
|
||||
return self.env.ref('website.action_website').read()[0]
|
||||
|
||||
|
||||
class Menu(models.Model):
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
@@ -19,6 +19,7 @@ var Dashboard = Widget.extend(ControlPanelMixin, {
|
||||
template: "website.WebsiteDashboardMain",
|
||||
events: {
|
||||
'click .js_link_analytics_settings': 'on_link_analytics_settings',
|
||||
'click .o_dashboard_action': 'on_dashboard_action_clicked',
|
||||
},
|
||||
|
||||
init: function(parent, context) {
|
||||
@@ -217,6 +218,23 @@ var Dashboard = Widget.extend(ControlPanelMixin, {
|
||||
this.update_cp();
|
||||
},
|
||||
|
||||
on_dashboard_action_clicked: function (ev) {
|
||||
ev.preventDefault();
|
||||
var $action = $(ev.currentTarget);
|
||||
var additional_context = {};
|
||||
if (this.date_range === 'week') {
|
||||
additional_context = {'search_default_week': true}
|
||||
} else if (this.date_range === 'month') {
|
||||
additional_context = {'search_default_month': true}
|
||||
} else if (this.date_range === 'year') {
|
||||
additional_context = {'search_default_year': true}
|
||||
}
|
||||
this.do_action($action.attr('name'), {
|
||||
additional_context: additional_context,
|
||||
on_reverse_breadcrumb: this.on_reverse_breadcrumb
|
||||
});
|
||||
},
|
||||
|
||||
update_cp: function() {
|
||||
var self = this;
|
||||
if (!this.$searchview) {
|
||||
|
||||
@@ -128,6 +128,74 @@
|
||||
}
|
||||
}
|
||||
|
||||
.o_dashboard_common {
|
||||
.o_box {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
justify-content: flex-start;
|
||||
> .o_box_item {
|
||||
@media (max-width: @screen-sm-min) {
|
||||
flex: 1 1 200px;
|
||||
display: block !important;
|
||||
}
|
||||
@media (min-width: @screen-sm-min) {
|
||||
flex: 0 0 20%;
|
||||
}
|
||||
}
|
||||
}
|
||||
.o_inner_box {
|
||||
padding-top: 10px;
|
||||
text-align: center;
|
||||
border: 1px solid @odoo-view-background-color;
|
||||
height: 80px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
&.o_main {
|
||||
background-color: @odoo-brand-optional;
|
||||
&:hover {
|
||||
background-color: darken(@odoo-brand-optional, 10%);
|
||||
}
|
||||
a {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
&.o_primary {
|
||||
background-color: @odoo-brand-primary;
|
||||
color: white;
|
||||
&:hover {
|
||||
background-color: darken(@odoo-brand-primary, 10%);
|
||||
}
|
||||
}
|
||||
&.o_apps {
|
||||
position: relative;
|
||||
background-color: @odoo-brand-optional;
|
||||
color: white;
|
||||
.o_apps_hidden {
|
||||
display: none;
|
||||
&.o_apps_hide_panel {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
background: @brand-danger;
|
||||
padding: 6px;
|
||||
}
|
||||
}
|
||||
&:hover {
|
||||
background-color: #45818E;
|
||||
.o_apps_show {
|
||||
display: none;
|
||||
}
|
||||
.o_apps_hidden {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
.o_highlight {
|
||||
font-size: 27px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.o_dashboard_visits {
|
||||
|
||||
.o_demo_background {
|
||||
|
||||
@@ -8,6 +8,20 @@
|
||||
<t t-name="website.WebsiteDashboardMain">
|
||||
<div class="o_dashboards">
|
||||
<div class="container-fluid o_website_dashboard">
|
||||
<t t-call="website.dashboard_header"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website.dashboard_header">
|
||||
<div class="row o_dashboard_common">
|
||||
<div class="o_box">
|
||||
<a href="#" class="o_box_item o_dashboard_action" name="website.action_website" title="Go to Website">
|
||||
<div class="o_inner_box o_primary">
|
||||
<i class="fa fa-globe fa-3x"></i><br/>
|
||||
Go to Website
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -373,6 +373,10 @@ You can also edit the fields of the Extra Step page in eCommerce checkout.">
|
||||
|
||||
<menuitem id="menu_website_global_configuration" parent="menu_website_configuration"
|
||||
sequence="100" name="Configuration" groups="base.group_system"/>
|
||||
<menuitem id="menu_website_website_settings" parent="menu_website_global_configuration" name="Settings" action="action_website_configuration"/>
|
||||
<menuitem name="Settings"
|
||||
id="menu_website_website_settings"
|
||||
action="action_website_configuration"
|
||||
parent="menu_website_global_configuration"
|
||||
groups="base.group_system"/>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- Menu items -->
|
||||
<menuitem name="Website Admin"
|
||||
<menuitem name="Website"
|
||||
id="menu_website_configuration"
|
||||
sequence="9"
|
||||
groups="website.group_website_publisher"
|
||||
web_icon="website,static/description/icon_admin.png"/>
|
||||
groups="base.group_user"
|
||||
web_icon="website,static/description/icon.png"/>
|
||||
|
||||
<!-- website views -->
|
||||
<record id="view_website_form" model="ir.ui.view">
|
||||
@@ -124,11 +124,17 @@
|
||||
<field name="tag">backend_dashboard</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_actions_server_website_dashboard" model="ir.actions.server">
|
||||
<field name="name">Website: Dashboard</field>
|
||||
<field name="model_id" ref="website.model_website"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.action_dashboard_redirect()</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_dashboard"
|
||||
name="Dashboard"
|
||||
sequence="1"
|
||||
action="website.backend_dashboard"
|
||||
groups="website.group_website_publisher"
|
||||
action="website.ir_actions_server_website_dashboard"
|
||||
parent="website.menu_website_configuration"/>
|
||||
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user