From de04e2309c0b7b798b8041ded1c7ad786eb9f93e Mon Sep 17 00:00:00 2001 From: Minh Tran Date: Fri, 25 Nov 2011 19:25:22 +0100 Subject: [PATCH 1/2] [IMP] After a module install from the installer, the user if fowarded to the module default screen bzr revid: mit@openerp.com-20111125182522-2dn2xt19rosv1sy6 --- .../web_dashboard/static/src/js/dashboard.js | 38 ++++++++++--------- .../static/src/xml/web_dashboard.xml | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/addons/web_dashboard/static/src/js/dashboard.js b/addons/web_dashboard/static/src/js/dashboard.js index 5d9c82af027..e3ee0e2b542 100644 --- a/addons/web_dashboard/static/src/js/dashboard.js +++ b/addons/web_dashboard/static/src/js/dashboard.js @@ -337,44 +337,44 @@ openerp.web_dashboard.apps = { applications: [ [ { - module: 'crm', name: 'CRM', + module: 'crm', name: 'CRM', menu: 'Sales', help: "Acquire leads, follow opportunities, manage prospects and phone calls, \u2026" }, { - module: 'sale', name: 'Sales', + module: 'sale', name: 'Sales', menu: 'Sales', help: "Do quotations, follow sales orders, invoice and control deliveries" }, { - module: 'account_voucher', name: 'Invoicing', + module: 'account_voucher', name: 'Invoicing', menu: 'Accounting', help: "Send invoice, track payments and reminders" }, { - module: 'point_of_sale', name: 'Point of Sales', + module: 'point_of_sale', name: 'Point of Sale', menu: 'Point of Sale', help: "Manage shop sales, use touch-screen POS" } ], [ { - module: 'purchase', name: 'Purchase', + module: 'purchase', name: 'Purchase', menu: 'Sales', help: "Do purchase orders, control invoices and reception, follow your suppliers, \u2026" }, { - module: 'stock', name: 'Warehouse', + module: 'stock', name: 'Warehouse', menu: 'Warehouse', help: "Track your stocks, schedule product moves, manage incoming and outgoing shipments, \u2026" }, { - module: 'mrp', name: 'Manufacturing', + module: 'mrp', name: 'Manufacturing', menu: 'Manufacturing', help: "Manage your manufacturing, control your supply chain, personalize master data, \u2026" }, { - module: 'account_accountant', name: 'Accounting and Finance', + module: 'account_accountant', name: 'Accounting and Finance', menu: 'Accounting', help: "Record financial operations, automate followup, manage multi-currency, \u2026" } ], [ { - module: 'project', name: 'Projects', + module: 'project', name: 'Projects', menu: 'Project', help: "Manage projects, track tasks, invoice task works, follow issues, \u2026" }, { - module: 'hr', name: 'Human Resources', + module: 'hr', name: 'Human Resources', menu: 'Human Resources', help: "Manage employees and their contracts, follow laves, recruit people, \u2026" }, { - module: 'marketing', name: 'Marketing', + module: 'marketing', name: 'Marketing', menu: 'Marketing', help: "Manage campaigns, follow activities, automate emails, \u2026" }, { - module: 'knowledge', name: 'Knowledge', + module: 'knowledge', name: 'Knowledge', menu: 'Knowledge', help: "Track your documents, browse your files, \u2026" } ] @@ -426,10 +426,10 @@ openerp.web_dashboard.ApplicationTiles = openerp.web.View.extend({ var installer = QWeb.render('StaticHome', render_ctx); self.$element.append(installer); this.$element.delegate('.oe-static-home-tile-text button', 'click', function () { - self.install_module($(this).val()); + self.install_module($(this).val(), $(this).data('menu')); }); }, - install_module: function (module_name) { + install_module: function (module_name, menu_name) { var self = this; var Modules = new openerp.web.DataSetSearch( this, 'ir.module.module', null, @@ -443,21 +443,23 @@ openerp.web_dashboard.ApplicationTiles = openerp.web.View.extend({ [_.pluck(records, 'id'), 'to install', ['uninstalled']], function () { Upgrade.call('upgrade_module', [[]], function () { - self.run_configuration_wizards(); + self.run_configuration_wizards(menu_name); }); } ) }); }, - run_configuration_wizards: function () { + run_configuration_wizards: function (menu_name) { var self = this; new openerp.web.DataSet(this, 'res.config').call('start', [[]], function (action) { self.widget_parent.widget_parent.do_action(action, function () { openerp.webclient.do_reload(); }); self.$element.empty(); - self.do_display_root_menu().then(function () { - $.unblockUI(); + var dss = new openerp.web.DataSetSearch(this, 'ir.ui.menu', null, [['parent_id', '=', false], ['name', '=', menu_name]]); + dss.read_slice(['id'], {}, function(menus) { + if(!(menus.length === 1)) { $.unblockUI(); return; } + $.when(openerp.webclient.menu.on_menu_click(null, menus[0].id)).then($.unblockUI); }); }); } diff --git a/addons/web_dashboard/static/src/xml/web_dashboard.xml b/addons/web_dashboard/static/src/xml/web_dashboard.xml index 9703013f777..6a0f2c52628 100644 --- a/addons/web_dashboard/static/src/xml/web_dashboard.xml +++ b/addons/web_dashboard/static/src/xml/web_dashboard.xml @@ -129,7 +129,7 @@

- +
From 4ca43cd31e4324531d2816af27d97546aafb1f1f Mon Sep 17 00:00:00 2001 From: Minh Tran Date: Mon, 5 Dec 2011 16:44:25 +0100 Subject: [PATCH 2/2] [IMP] Changed the default home page bzr revid: mit@openerp.com-20111205154425-fw94io3x1dagpc5h --- addons/web/static/src/js/chrome.js | 10 +-- .../web_dashboard/static/src/js/dashboard.js | 69 +----------------- addons/web_default_home/__init__.py | 0 addons/web_default_home/__openerp__.py | 14 ++++ .../static/src/css/default_home.css | 47 ++++++++++++ .../static/src/js/default_home.js | 73 +++++++++++++++++++ .../static/src/xml/default_home.xml | 21 ++++++ 7 files changed, 158 insertions(+), 76 deletions(-) create mode 100644 addons/web_default_home/__init__.py create mode 100644 addons/web_default_home/__openerp__.py create mode 100644 addons/web_default_home/static/src/css/default_home.css create mode 100644 addons/web_default_home/static/src/js/default_home.js create mode 100644 addons/web_default_home/static/src/xml/default_home.xml diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index f10ee9376f6..d0a156ad9e5 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1061,15 +1061,7 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie // TODO: add actual loading if there is url state to unpack, test on window.location.hash // not logged in if (!this.session.uid) { return; } - var ds = new openerp.web.DataSetSearch(this, 'res.users'); - ds.read_ids([this.session.uid], ['action_id'], function (users) { - var home_action = users[0].action_id; - if (!home_action) { - self.default_home(); - return; - } - self.execute_home_action(home_action[0], ds); - }) + self.action_manager.do_action({type: 'ir.actions.client', tag: 'default_home'}); }, default_home: function () { }, diff --git a/addons/web_dashboard/static/src/js/dashboard.js b/addons/web_dashboard/static/src/js/dashboard.js index e3ee0e2b542..2374acbec7a 100644 --- a/addons/web_dashboard/static/src/js/dashboard.js +++ b/addons/web_dashboard/static/src/js/dashboard.js @@ -385,21 +385,6 @@ openerp.web_dashboard.ApplicationTiles = openerp.web.View.extend({ start: function () { var self = this; this._super(); - // Check for installed application - var Installer = new openerp.web.DataSet(this, 'base.setup.installer'); - Installer.call('default_get', [], function (installed_modules) { - var installed = _(installed_modules).any(function (active, name) { - return _.str.startsWith(name, 'cat') && active; }); - - if(installed) { - self.do_display_root_menu(); - } else { - self.do_display_installer(); - } - }); - }, - do_display_root_menu: function() { - var self = this; var dss = new openerp.web.DataSetSearch( this, 'ir.ui.menu', null, [['parent_id', '=', false]]); var r = dss.read_slice( ['name', 'web_icon_data', 'web_icon_hover_data'], {}, function (applications) { // Create a matrix of 3*x applications @@ -408,58 +393,8 @@ openerp.web_dashboard.ApplicationTiles = openerp.web.View.extend({ rows.push(applications.splice(0, 3)); } var tiles = QWeb.render( 'ApplicationTiles.content', {rows: rows}); - self.$element.append(tiles) - .find('.oe-dashboard-home-tile') - .click(function () { - openerp.webclient.menu.on_menu_click(null, $(this).data('menuid')) - }); - }); - return r; - }, - do_display_installer: function() { - var self = this; - var render_ctx = { - url: window.location.protocol + '//' + window.location.host + window.location.pathname, - session: self.session, - rows: openerp.web_dashboard.apps.applications - }; - var installer = QWeb.render('StaticHome', render_ctx); - self.$element.append(installer); - this.$element.delegate('.oe-static-home-tile-text button', 'click', function () { - self.install_module($(this).val(), $(this).data('menu')); - }); - }, - install_module: function (module_name, menu_name) { - var self = this; - var Modules = new openerp.web.DataSetSearch( - this, 'ir.module.module', null, - [['name', '=', module_name], ['state', '=', 'uninstalled']]); - var Upgrade = new openerp.web.DataSet(this, 'base.module.upgrade'); - - $.blockUI(); - Modules.read_slice(['id'], {}, function (records) { - if (!(records.length === 1)) { $.unblockUI(); return; } - Modules.call('state_update', - [_.pluck(records, 'id'), 'to install', ['uninstalled']], - function () { - Upgrade.call('upgrade_module', [[]], function () { - self.run_configuration_wizards(menu_name); - }); - } - ) - }); - }, - run_configuration_wizards: function (menu_name) { - var self = this; - new openerp.web.DataSet(this, 'res.config').call('start', [[]], function (action) { - self.widget_parent.widget_parent.do_action(action, function () { - openerp.webclient.do_reload(); - }); - self.$element.empty(); - var dss = new openerp.web.DataSetSearch(this, 'ir.ui.menu', null, [['parent_id', '=', false], ['name', '=', menu_name]]); - dss.read_slice(['id'], {}, function(menus) { - if(!(menus.length === 1)) { $.unblockUI(); return; } - $.when(openerp.webclient.menu.on_menu_click(null, menus[0].id)).then($.unblockUI); + self.$element.append(tiles).find('.oe-dashboard-home-tile').click(function () { + openerp.webclient.menu.on_menu_click(null, $(this).data('menuid')) }); }); } diff --git a/addons/web_default_home/__init__.py b/addons/web_default_home/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/addons/web_default_home/__openerp__.py b/addons/web_default_home/__openerp__.py new file mode 100644 index 00000000000..ece173c8581 --- /dev/null +++ b/addons/web_default_home/__openerp__.py @@ -0,0 +1,14 @@ +{ + "name": "web Default Home", + "category" : "Hidden", + "version": "2.0", + "depends": ['web'], + "js": [ + 'static/src/js/default_home.js' + ], + "css": ['static/src/css/default_home.css'], + 'qweb' : [ + "static/src/xml/*.xml", + ], + 'active': True +} diff --git a/addons/web_default_home/static/src/css/default_home.css b/addons/web_default_home/static/src/css/default_home.css new file mode 100644 index 00000000000..96a6f9f4e82 --- /dev/null +++ b/addons/web_default_home/static/src/css/default_home.css @@ -0,0 +1,47 @@ +.installer { + width: 980px; +} + +.installer h1, .installer h3 { + margin: 16px 24px; + color: #555 +} + +.installer li { + float: left; + list-style: none; +} + +.installer li img { + display: block; + margin: 12px auto 16px; + height: 64px; + width: 64px; +} + +.installer li div { + color: #555; +} + +.installer li a { + display: block; + height: 120px; + width: 194px; + border: 1px solid #f4f2f2; + margin: 6px; + padding: 12px; + text-align: center; + text-transform: uppercase; + text-decoration: none; + font-size: 12px; + font-weight: 800; + background: white; + -moz-border-radius: 6px; + -webkit-border-radius: 6px; + -ms-border-radius: 6px; + border-radius: 6px; + -moz-box-shadow: 0 1px 2px #bbb; + -webkit-box-shadow: 0 1px 2px #bbb; + -o-box-shadow: 0 1px 2px #bbb; + box-shadow: 0 1px 2px #bbb; +} diff --git a/addons/web_default_home/static/src/js/default_home.js b/addons/web_default_home/static/src/js/default_home.js new file mode 100644 index 00000000000..0a95ace0681 --- /dev/null +++ b/addons/web_default_home/static/src/js/default_home.js @@ -0,0 +1,73 @@ +openerp.web_default_home = function(openerp) { + var QWeb = openerp.web.qweb; + + openerp.web.client_actions.add('default_home', 'openerp.web.Welcome'); + openerp.web.Welcome = openerp.web.Widget.extend({ + init: function(parent) { + this._super(parent); + }, + start: function() { + var self = this; + var applications = [ + {module: 'crm', name: 'CRM', menu: 'Sales', help: "Acquire leads, follow opportunities, manage prospects and phone calls, \u2026"}, + {module: 'sale', name: 'Sales', menu: 'Sales', help: "Do quotations, follow sales orders, invoice and control deliveries"}, + {module: 'account_voucher', name: 'Invoicing', menu: 'Accounting', help: "Send invoice, track payments and reminders"}, + {module: 'point_of_sale', name: 'Point of Sale', menu: 'Point of Sale', help: "Manage shop sales, use touch-screen POS"}, + {module: 'purchase', name: 'Purchase', menu: 'Sales', help: "Do purchase orders, control invoices and reception, follow your suppliers, \u2026"}, + {module: 'stock', name: 'Warehouse', menu: 'Warehouse', help: "Track your stocks, schedule product moves, manage incoming and outgoing shipments, \u2026"}, + {module: 'mrp', name: 'Manufacturing', menu: 'Manufacturing', help: "Manage your manufacturing, control your supply chain, personalize master data, \u2026"}, + {module: 'account_accountant', name: 'Accounting & Finance', menu: 'Accounting', help: "Record financial operations, automate followup, manage multi-currency, \u2026"}, + {module: 'project', name: 'Projects', menu: 'Project', help: "Manage projects, track tasks, invoice task works, follow issues, \u2026"}, + {module: 'hr', name: 'Human Resources', menu: 'Human Resources', help: "Manage employees and their contracts, follow laves, recruit people, \u2026"}, + {module: 'marketing', name: 'Marketing', menu: 'Marketing', help: "Manage campaigns, follow activities, automate emails, \u2026"}, + {module: 'knowledge', name: 'Knowledge', menu: 'Knowledge', help: "Track your documents, browse your files, \u2026"} + ]; + + var Installer = new openerp.web.DataSet(this, 'base.setup.installer'); + Installer.call('default_get', [], function (installed_modules) { + console.log(installed_modules); + self.$element.html(QWeb.render('Welcome-Page', {'applications': applications})); + self.$element.find('.install-module-link').click(function () { + self.install_module($(this).data('module'), $(this).data('menu')); + return false; + }); + }); + }, + install_module: function (module_name, menu_name) { + var self = this; + var Modules = new openerp.web.DataSetSearch( + this, 'ir.module.module', null, + [['name', '=', module_name], ['state', '=', 'uninstalled']]); + var Upgrade = new openerp.web.DataSet(this, 'base.module.upgrade'); + + $.blockUI(); + Modules.read_slice(['id'], {}, function (records) { + if (!(records.length === 1)) { $.unblockUI(); return; } + Modules.call('state_update', + [_.pluck(records, 'id'), 'to install', ['uninstalled']], + function () { + Upgrade.call('upgrade_module', [[]], function () { + self.run_configuration_wizards(menu_name); + }); + } + ) + }); + }, + run_configuration_wizards: function (menu_name) { + var self = this; + new openerp.web.DataSet(this, 'res.config').call('start', [[]], function (action) { + self.widget_parent.widget_parent.do_action(action, function () { + openerp.webclient.do_reload(); + }); + self.$element.empty(); + var dss = new openerp.web.DataSetSearch(this, 'ir.ui.menu', null, [['parent_id', '=', false], ['name', '=', menu_name]]); + dss.read_slice(['id'], {}, function(menus) { + if(!(menus.length === 1)) { $.unblockUI(); return; } + $.when(openerp.webclient.menu.on_menu_click(null, menus[0].id)).then($.unblockUI); + }); + }); + } + }); + +}; + diff --git a/addons/web_default_home/static/src/xml/default_home.xml b/addons/web_default_home/static/src/xml/default_home.xml new file mode 100644 index 00000000000..4d9e4a26938 --- /dev/null +++ b/addons/web_default_home/static/src/xml/default_home.xml @@ -0,0 +1,21 @@ + + + + +
+

Welcome to OpenERP

+

Please choose the first application to install.

+ +
+
+ +