summaryrefslogtreecommitdiff
path: root/addons/web_settings_dashboard
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web_settings_dashboard')
-rw-r--r--addons/web_settings_dashboard/controllers/main.py7
-rw-r--r--addons/web_settings_dashboard/static/src/js/dashboard.js21
-rw-r--r--addons/web_settings_dashboard/static/src/xml/dashboard.xml3
3 files changed, 30 insertions, 1 deletions
diff --git a/addons/web_settings_dashboard/controllers/main.py b/addons/web_settings_dashboard/controllers/main.py
index 21423ec902d..d2a23fc7c65 100644
--- a/addons/web_settings_dashboard/controllers/main.py
+++ b/addons/web_settings_dashboard/controllers/main.py
@@ -53,6 +53,12 @@ class WebSettingsDashboard(http.Controller):
enterprise_users = request.env['res.users'].search_count([("login_date", ">=", fields.Datetime.to_string(limit_date)), ('share', '=', False)])
expiration_date = request.env['ir.config_parameter'].sudo().get_param('database.expiration_date')
+
+ # We assume that if there's at least one module with demo data active, then the db was
+ # initialized with demo=True or it has been force-activated by the `Load demo data` button
+ # in the settings dashboard.
+ demo_active = bool(request.env['ir.module.module'].search_count([('demo', '=', True)]))
+
return {
'apps': {
'installed_apps': installed_apps,
@@ -68,6 +74,7 @@ class WebSettingsDashboard(http.Controller):
'server_version': release.version,
'expiration_date': expiration_date,
'debug': request.debug,
+ 'demo_active': demo_active,
},
'company': {
'company_id': request.env.user.company_id.id,
diff --git a/addons/web_settings_dashboard/static/src/js/dashboard.js b/addons/web_settings_dashboard/static/src/js/dashboard.js
index 9f0ed3d7552..4d58da38041 100644
--- a/addons/web_settings_dashboard/static/src/js/dashboard.js
+++ b/addons/web_settings_dashboard/static/src/js/dashboard.js
@@ -2,6 +2,7 @@ odoo.define('web_settings_dashboard', function (require) {
"use strict";
var AbstractAction = require('web.AbstractAction');
+var config = require('web.config');
var core = require('web.core');
var framework = require('web.framework');
var Widget = require('web.Widget');
@@ -279,6 +280,7 @@ var DashboardShare = Widget.extend({
'click .tw_share': 'share_twitter',
'click .fb_share': 'share_facebook',
'click .li_share': 'share_linkedin',
+ 'click .o_web_settings_dashboard_force_demo': '_onClickForceDemo',
},
init: function (parent, data) {
@@ -286,6 +288,7 @@ var DashboardShare = Widget.extend({
this.parent = parent;
this.share_url = 'https://www.odoo.com';
this.share_text = encodeURIComponent("I am using #Odoo - Awesome open source business apps.");
+ return this._super.apply(this, arguments);
},
/**
@@ -319,7 +322,23 @@ var DashboardShare = Widget.extend({
popup_url,
'Share Dialog',
'width=600,height=400'); // We have to add a size otherwise the window pops in a new tab
- }
+ },
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * Forces demo data to be installed in a database without demo data installed.
+ *
+ * @private
+ * @param {MouseEvent} ev
+ */
+ _onClickForceDemo: function (ev) {
+ ev.preventDefault();
+ this.do_action('base.demo_force_install_action');
+ config.debug = false;
+ },
});
var DashboardTranslations = Widget.extend({
diff --git a/addons/web_settings_dashboard/static/src/xml/dashboard.xml b/addons/web_settings_dashboard/static/src/xml/dashboard.xml
index 5a505bb02e4..a98a557d66d 100644
--- a/addons/web_settings_dashboard/static/src/xml/dashboard.xml
+++ b/addons/web_settings_dashboard/static/src/xml/dashboard.xml
@@ -109,6 +109,7 @@
<hr/>
<t t-set="server_version" t-value="widget.data.server_version"/>
<t t-set="debug" t-value="widget.data.debug"/>
+ <t t-set="demo_active" t-value="widget.data.demo_active"/>
<div class="row">
<div class="text-center">
<div class="user-heading">
@@ -134,6 +135,8 @@
<a t-if="debug != 'assets'" class="oe_activate_debug_mode pull-right" href="?debug=assets" >Activate the developer mode (with assets)</a>
<br t-if="debug != 'assets'"/>
<a t-if="debug != false" class="oe_activate_debug_mode pull-right" href="/web" >Deactivate the developer mode</a>
+ <br t-if="debug != false"/>
+ <a t-if="(debug) and !(demo_active)" class="oe_activate_debug_mode pull-right o_web_settings_dashboard_force_demo" href="#">Load demo data</a>
</div>
</div>
</div>