From f38d0f6736f1d5e82aecbf70d64fee99f6ae0786 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 5 Jun 2012 14:45:51 +0530 Subject: [PATCH 01/17] [IMP]create widget for add to dashboard. bzr revid: vme@tinyerp.com-20120605091551-pecg3070vi94jxeu --- addons/web/static/src/js/search.js | 66 +++++++++--------------------- addons/web/static/src/xml/base.xml | 9 +++- 2 files changed, 27 insertions(+), 48 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index f9e737471ae..f7eff8cddd5 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -635,6 +635,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea (new instance.web.search.CustomFilters(this)); // add Advanced to this.inputs (new instance.web.search.Advanced(this)); + (new instance.web.search.AddToDashboard(this)); // build drawer var drawer_started = $.when.apply( @@ -692,53 +693,6 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea select.val(''); } }, - on_add_to_dashboard: function() { - this.$element.find(".oe_search-view-filters-management")[0].selectedIndex = 0; - var self = this, - menu = instance.webclient.menu, - $dialog = $(QWeb.render("SearchView.add_to_dashboard", { - dashboards : menu.data.data.children, - selected_menu_id : menu.$element.find('a.active').data('menu') - })); - $dialog.find('input').val(this.fields_view.name); - instance.web.dialog($dialog, { - modal: true, - title: _t("Add to Dashboard"), - buttons: [ - {text: _t("Cancel"), click: function() { - $(this).dialog("close"); - }}, - {text: _t("OK"), click: function() { - $(this).dialog("close"); - var menu_id = $(this).find("select").val(), - title = $(this).find("input").val(), - data = self.build_search_data(), - context = new instance.web.CompoundContext(), - domain = new instance.web.CompoundDomain(); - _.each(data.contexts, function(x) { - context.add(x); - }); - _.each(data.domains, function(x) { - domain.add(x); - }); - self.rpc('/web/searchview/add_to_dashboard', { - menu_id: menu_id, - action_id: self.getParent().action.id, - context_to_save: context, - domain: domain, - view_mode: self.getParent().active_view, - name: title - }, function(r) { - if (r === false) { - self.do_warn("Could not add filter to dashboard"); - } else { - self.do_notify("Filter added to dashboard", ''); - } - }); - }} - ] - }); - }, /** * Extract search data from the view's facets. * @@ -1671,6 +1625,24 @@ instance.web.search.Filters = instance.web.search.Input.extend({ })); } }); +instance.web.search.AddToDashboard = instance.web.search.Input.extend({ + template: 'SearchView.addtodashboard', + _in_drawer: true, + init: function(){ + var menu = instance.webclient.menu; + var menu_id = menu.$secondary_menus.find("li.oe_active a").data('menu') + this._super.apply(this, arguments); + }, + start: function () { + var self = this; + this.$element.on('click', 'h4', this.proxy('show_option')) + }, + show_option:function(){ + self.$element.toggleClass('oe_opened'); + console.log(this); + } + +}) instance.web.search.Advanced = instance.web.search.Input.extend({ template: 'SearchView.advanced', _in_drawer: true, diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index aaecd258412..2ca3aac9680 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1264,7 +1264,6 @@ - @@ -1423,6 +1422,14 @@
+
+

Add to Dashboard

+ +

Advanced Search

From a91e66b76b14c11974429ad8a64b36e5c6f66dee Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 6 Jun 2012 10:07:10 +0530 Subject: [PATCH 02/17] [IMP]improvements to dashboard. bzr revid: vme@tinyerp.com-20120606043710-prr9se9pz184dntx --- addons/web/static/src/js/search.js | 46 +++++++++++++++++++++++++++--- addons/web/static/src/xml/base.xml | 25 ++++++++-------- 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index f7eff8cddd5..8cc9b807db1 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1630,16 +1630,54 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ _in_drawer: true, init: function(){ var menu = instance.webclient.menu; - var menu_id = menu.$secondary_menus.find("li.oe_active a").data('menu') + console.log("menu",menu); + this.menu_data = _.map(menu.data.data.children, + function(menu){ + console.log(menu); + var obj = {}; obj["id"] = menu.id; obj["name"] = menu.name; return obj; + //support after update of _.underscore.js lib 1.3.3 + //return _.pick(menu, 'id', 'name'); + }); + this.selected_menu_id = menu.$element.find('a.oe_active').data('menu'); this._super.apply(this, arguments); }, start: function () { var self = this; - this.$element.on('click', 'h4', this.proxy('show_option')) + this.$element + .on('click', 'h4', this.proxy('show_option')) + .on('submit', 'form', function (e) {e.preventDefault(); self.add_dashboard();}); + this.$element.find('.searchview_extended_delete_prop').click(function () {self.$element.toggleClass('oe_opened');}); + }, + add_dashboard:function(){ + this.$element.toggleClass('oe_opened'); + var menu_id = this.$element.find("select").val(); + var ds_name = this.$element.find("input").val(); + data = this.getParent().build_search_data(); + context = new instance.web.CompoundContext(), + domain = new instance.web.CompoundDomain(); + _.each(data.contexts, function(x) {context.add(x);}); + _.each(data.domains, function(x) {domain.add(x);}); + this.rpc('/web/searchview/add_to_dashboard', { + menu_id: menu_id, + action_id: this.view.getParent().action.id, + context_to_save: context, + domain: domain, + view_mode: this.view.getParent().active_view, + name: ds_name + }, function(r) { + if (r === false) { + self.do_warn("Could not add filter to dashboard"); + } else { + self.do_notify("Filter added to dashboard", ''); + } + }); }, show_option:function(){ - self.$element.toggleClass('oe_opened'); - console.log(this); + this.$element.toggleClass('oe_opened'); + if (! this.$element.hasClass('oe_opened')) + return; + var action_id = this.view.getParent().action.id; + this.$element.find("input").val(this.getParent().fields_view.name ); } }) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 2ca3aac9680..060bf29b36b 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1274,16 +1274,6 @@

(Any existing filter with the same name will be replaced)

- -
-

Select Dashboard to add this filter to:

- -

Title of new Dashboard item:

- -
-
@@ -1422,13 +1412,22 @@
-
+

Add to Dashboard

+
    - + + + + + x +
+

Advanced Search

From ff00c0f6355ef4af21d46b79516825a48ef513f4 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 7 Jun 2012 16:00:29 +0530 Subject: [PATCH 03/17] [IMP]Dashboard items added. bzr revid: vme@tinyerp.com-20120607103029-0iumqrzigswzpny8 --- addons/web/controllers/main.py | 23 +++++++++++++--- addons/web/static/src/js/search.js | 42 ++++++++++++------------------ addons/web/static/src/xml/base.xml | 12 +++++---- 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 6eb8ed94909..4e32af020e3 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1286,14 +1286,29 @@ class SearchView(View): del filter['context'] del filter['domain'] return filters - + + @openerpweb.jsonrequest + def get_all_dashboard(self, req): + all_dashboard = [] + Model = req.session.model('ir.actions.act_window') + Dashboard_Menus = req.session.model('ir.values') + Dashboard_act_window = Model.search_read([('res_model','=',"board.board"), ('view_id','!=', False) ],['name','id']) + for i in Dashboard_act_window: + tuple_of_dashboard = "ir.actions.act_window," + str(i["id"]) + menu_id = Dashboard_Menus.search_read([('value','=',tuple_of_dashboard)],['res_id']) + if menu_id: + all_dashboard.append({"res_id":menu_id[0]["res_id"],"name":i["name"]}) + return all_dashboard + @openerpweb.jsonrequest def add_to_dashboard(self, req, menu_id, action_id, context_to_save, domain, view_mode, name=''): - ctx = common.nonliterals.CompoundContext(context_to_save) - ctx.session = req.session - ctx = ctx.evaluate() + to_eval = common.nonliterals.CompoundContext(context_to_save) + to_eval.session = req.session + ctx = dict((k, v) for k, v in to_eval.evaluate().iteritems() + if not k.startswith('search_default_')) ctx['dashboard_merge_domains_contexts'] = False # TODO: replace this 6.1 workaround by attribute on domain = common.nonliterals.CompoundDomain(domain) + print "domainnnnn",domain domain.session = req.session domain = domain.evaluate() diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 8cc9b807db1..0e14a6ad161 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1628,42 +1628,36 @@ instance.web.search.Filters = instance.web.search.Input.extend({ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ template: 'SearchView.addtodashboard', _in_drawer: true, - init: function(){ - var menu = instance.webclient.menu; - console.log("menu",menu); - this.menu_data = _.map(menu.data.data.children, - function(menu){ - console.log(menu); - var obj = {}; obj["id"] = menu.id; obj["name"] = menu.name; return obj; - //support after update of _.underscore.js lib 1.3.3 - //return _.pick(menu, 'id', 'name'); - }); - this.selected_menu_id = menu.$element.find('a.oe_active').data('menu'); - this._super.apply(this, arguments); - }, start: function () { var self = this; this.$element .on('click', 'h4', this.proxy('show_option')) .on('submit', 'form', function (e) {e.preventDefault(); self.add_dashboard();}); this.$element.find('.searchview_extended_delete_prop').click(function () {self.$element.toggleClass('oe_opened');}); + return this.rpc('/web/searchview/get_all_dashboard', {}, function(r) {self.menu_data = r;}).pipe(this.proxy("render_data")) + }, + render_data: function(){ + var self = this; + var selection = instance.web.qweb.render("SearchView.addtodashboard.selection",{selections:this.menu_data}); + this.$element.find("input").before(selection) }, add_dashboard:function(){ + var self = this,getParent = this.getParent(),view_parent = this.view.getParent(); + if(!view_parent.action || !this.$element.find("select").val()) + return this.do_warn("Can't add dashboard item"); + data = getParent.build_search_data(), + context = new instance.web.CompoundContext(getParent.dataset.get_context() || []), + domain = new instance.web.CompoundDomain(getParent.dataset.get_domain() || []); this.$element.toggleClass('oe_opened'); - var menu_id = this.$element.find("select").val(); - var ds_name = this.$element.find("input").val(); - data = this.getParent().build_search_data(); - context = new instance.web.CompoundContext(), - domain = new instance.web.CompoundDomain(); _.each(data.contexts, function(x) {context.add(x);}); _.each(data.domains, function(x) {domain.add(x);}); this.rpc('/web/searchview/add_to_dashboard', { - menu_id: menu_id, - action_id: this.view.getParent().action.id, + menu_id: this.$element.find("select").val(), + action_id: view_parent.action.id, context_to_save: context, domain: domain, - view_mode: this.view.getParent().active_view, - name: ds_name + view_mode: view_parent.active_view, + name: this.$element.find("input").val() }, function(r) { if (r === false) { self.do_warn("Could not add filter to dashboard"); @@ -1676,10 +1670,8 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ this.$element.toggleClass('oe_opened'); if (! this.$element.hasClass('oe_opened')) return; - var action_id = this.view.getParent().action.id; - this.$element.find("input").val(this.getParent().fields_view.name ); + this.$element.find("input").val(this.getParent().fields_view.name || "" ); } - }) instance.web.search.Advanced = instance.web.search.Input.extend({ template: 'SearchView.advanced', diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 060bf29b36b..73101c5d0bf 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1417,11 +1417,6 @@
  • - - x @@ -1429,6 +1424,13 @@
+ + +

Advanced Search

From abc614182662fa9fd3b8c9cf8ed883abe556f14d Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 7 Jun 2012 17:01:47 +0530 Subject: [PATCH 04/17] [IMP]improvements. bzr revid: vme@tinyerp.com-20120607113147-7lly2zl317b8n88v --- addons/web/static/src/css/base.sass | 12 ++++++++++++ addons/web/static/src/js/search.js | 30 ++++++++++++++--------------- addons/web/static/src/xml/base.xml | 6 +++--- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 0c8f4253549..782a8f1012b 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1145,6 +1145,18 @@ $colour4: #8a89ba position: absolute top: 0 right: 5px + .oe_searchview_dashboard + form + display: none + margin-top: 2px + ul + list-style: none + padding: 0 + li + position: relative + list-style: none + margin: 0 + white-space: nowrap .oe_searchview_advanced form display: none diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 0e14a6ad161..a0eab2ffb63 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1644,7 +1644,7 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ add_dashboard:function(){ var self = this,getParent = this.getParent(),view_parent = this.view.getParent(); if(!view_parent.action || !this.$element.find("select").val()) - return this.do_warn("Can't add dashboard item"); + return this.do_warn("Can't find dashboard action"); data = getParent.build_search_data(), context = new instance.web.CompoundContext(getParent.dataset.get_context() || []), domain = new instance.web.CompoundDomain(getParent.dataset.get_domain() || []); @@ -1652,19 +1652,19 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ _.each(data.contexts, function(x) {context.add(x);}); _.each(data.domains, function(x) {domain.add(x);}); this.rpc('/web/searchview/add_to_dashboard', { - menu_id: this.$element.find("select").val(), - action_id: view_parent.action.id, - context_to_save: context, - domain: domain, - view_mode: view_parent.active_view, - name: this.$element.find("input").val() - }, function(r) { - if (r === false) { - self.do_warn("Could not add filter to dashboard"); - } else { - self.do_notify("Filter added to dashboard", ''); - } - }); + menu_id: this.$element.find("select").val(), + action_id: view_parent.action.id, + context_to_save: context, + domain: domain, + view_mode: view_parent.active_view, + name: this.$element.find("input").val() + }, function(r) { + if (r === false) { + self.do_warn("Could not add filter to dashboard"); + } else { + self.do_notify("Filter added to dashboard", ''); + } + }); }, show_option:function(){ this.$element.toggleClass('oe_opened'); @@ -1672,7 +1672,7 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ return; this.$element.find("input").val(this.getParent().fields_view.name || "" ); } -}) +}); instance.web.search.Advanced = instance.web.search.Input.extend({ template: 'SearchView.advanced', _in_drawer: true, diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 73101c5d0bf..74a07e02035 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1412,12 +1412,12 @@
-
+

Add to Dashboard

  • - + x
  • @@ -1425,7 +1425,7 @@
- From c9ffd24d9ee0876a7061a97d000dea531633c85f Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 7 Jun 2012 17:20:28 +0530 Subject: [PATCH 05/17] [IMP] Removed base sass file for dashboard css changes. bzr revid: vme@tinyerp.com-20120607115028-1362ld4x8xmkcl8e --- addons/web/static/src/css/base.sass | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 4ee0dcf1dfb..df40fc8d151 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1145,18 +1145,6 @@ $colour4: #8a89ba position: absolute top: 0 right: 5px - .oe_searchview_dashboard - form - display: none - margin-top: 2px - ul - list-style: none - padding: 0 - li - position: relative - list-style: none - margin: 0 - white-space: nowrap .oe_searchview_advanced form display: none From 78e9cc82271c90df178aa64cd67505c1e4670994 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 7 Jun 2012 17:51:17 +0530 Subject: [PATCH 06/17] [IMP]improve base.css and base.sass bzr revid: vme@tinyerp.com-20120607122117-s0uvanzd85bra306 --- addons/web/static/src/css/base.css | 14 ++++++++++++++ addons/web/static/src/css/base.sass | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 2988c0aa634..c599d62ccba 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1456,6 +1456,20 @@ top: 0; right: 5px; } +.openerp .oe_searchview .oe_searchview_drawer .oe_searchview_dashboard form { + display: none; + margin-top: 2px; +} +.openerp .oe_searchview .oe_searchview_drawer .oe_searchview_dashboard ul { + list-style: none; + padding: 0; +} +.openerp .oe_searchview .oe_searchview_drawer .oe_searchview_dashboard li { + position: relative; + list-style: none; + margin: 0; + white-space: nowrap; +} .openerp .oe_searchview .oe_searchview_drawer .oe_searchview_advanced form { display: none; margin-top: 8px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index df40fc8d151..4ee0dcf1dfb 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1145,6 +1145,18 @@ $colour4: #8a89ba position: absolute top: 0 right: 5px + .oe_searchview_dashboard + form + display: none + margin-top: 2px + ul + list-style: none + padding: 0 + li + position: relative + list-style: none + margin: 0 + white-space: nowrap .oe_searchview_advanced form display: none From b92d420e56ba1637f7da3ae13aa56693d5a5d1a2 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 7 Jun 2012 17:59:52 +0530 Subject: [PATCH 07/17] [IMP]remove tuple. bzr revid: vme@tinyerp.com-20120607122952-u3ifuam13bendtbj --- addons/web/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 4e32af020e3..8fef897addb 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1292,7 +1292,7 @@ class SearchView(View): all_dashboard = [] Model = req.session.model('ir.actions.act_window') Dashboard_Menus = req.session.model('ir.values') - Dashboard_act_window = Model.search_read([('res_model','=',"board.board"), ('view_id','!=', False) ],['name','id']) + Dashboard_act_window = Model.search_read([('res_model','=',"board.board")],['name','id']) for i in Dashboard_act_window: tuple_of_dashboard = "ir.actions.act_window," + str(i["id"]) menu_id = Dashboard_Menus.search_read([('value','=',tuple_of_dashboard)],['res_id']) From 2a51b719c93b9a8913f4aa751980966bc129856c Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 7 Jun 2012 18:03:29 +0530 Subject: [PATCH 08/17] [REM]removed print statement. bzr revid: vme@tinyerp.com-20120607123329-ae2yks21e4iu4i09 --- addons/web/controllers/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 8fef897addb..e2941439258 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1308,7 +1308,6 @@ class SearchView(View): if not k.startswith('search_default_')) ctx['dashboard_merge_domains_contexts'] = False # TODO: replace this 6.1 workaround by attribute on domain = common.nonliterals.CompoundDomain(domain) - print "domainnnnn",domain domain.session = req.session domain = domain.evaluate() From a97492b20f3d620ecb84547027bfd84db227402b Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 15 Jun 2012 18:32:45 +0530 Subject: [PATCH 09/17] [IMP]remove unnecessary code. bzr revid: vme@tinyerp.com-20120615130245-0ckjqkh99liirdo7 --- addons/web/static/src/js/search.js | 1 - addons/web/static/src/xml/base.xml | 5 ----- 2 files changed, 6 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index a0eab2ffb63..9ee11a55a19 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1633,7 +1633,6 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ this.$element .on('click', 'h4', this.proxy('show_option')) .on('submit', 'form', function (e) {e.preventDefault(); self.add_dashboard();}); - this.$element.find('.searchview_extended_delete_prop').click(function () {self.$element.toggleClass('oe_opened');}); return this.rpc('/web/searchview/get_all_dashboard', {}, function(r) {self.menu_data = r;}).pipe(this.proxy("render_data")) }, render_data: function(){ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 4ae8d4d775d..1e2318a426a 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1421,13 +1421,8 @@

Add to Dashboard

-
    -
  • - x -
  • -
From 2b33e4914a0e11cc48a8b31833c5f8522bccd09b Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 20 Jun 2012 15:08:13 +0530 Subject: [PATCH 10/17] [IMP]remove python code. bzr revid: vme@tinyerp.com-20120620093813-a11mc1p64407jk6d --- addons/web/controllers/main.py | 12 ------------ addons/web/static/src/js/search.js | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index e2941439258..f67e6837af7 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1287,18 +1287,6 @@ class SearchView(View): del filter['domain'] return filters - @openerpweb.jsonrequest - def get_all_dashboard(self, req): - all_dashboard = [] - Model = req.session.model('ir.actions.act_window') - Dashboard_Menus = req.session.model('ir.values') - Dashboard_act_window = Model.search_read([('res_model','=',"board.board")],['name','id']) - for i in Dashboard_act_window: - tuple_of_dashboard = "ir.actions.act_window," + str(i["id"]) - menu_id = Dashboard_Menus.search_read([('value','=',tuple_of_dashboard)],['res_id']) - if menu_id: - all_dashboard.append({"res_id":menu_id[0]["res_id"],"name":i["name"]}) - return all_dashboard @openerpweb.jsonrequest def add_to_dashboard(self, req, menu_id, action_id, context_to_save, domain, view_mode, name=''): diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 9ee11a55a19..978ea42c8dd 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1633,8 +1633,22 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ this.$element .on('click', 'h4', this.proxy('show_option')) .on('submit', 'form', function (e) {e.preventDefault(); self.add_dashboard();}); - return this.rpc('/web/searchview/get_all_dashboard', {}, function(r) {self.menu_data = r;}).pipe(this.proxy("render_data")) + //return this.rpc('/web/searchview/get_all_dashboard', {}, function(r) {self.menu_data = r;}).pipe(this.proxy("render_data")) }, + /* + * @openerpweb.jsonrequest + def get_all_dashboard(self, req): + all_dashboard = [] + Model = req.session.model('ir.actions.act_window') + Dashboard_Menus = req.session.model('ir.values') + Dashboard_act_window = Model.search_read([('res_model','=',"board.board")],['name','id']) + for i in Dashboard_act_window: + tuple_of_dashboard = "ir.actions.act_window," + str(i["id"]) + menu_id = Dashboard_Menus.search_read([('value','=',tuple_of_dashboard)],['res_id']) + if menu_id: + all_dashboard.append({"res_id":menu_id[0]["res_id"],"name":i["name"]}) + return all_dashboard + */ render_data: function(){ var self = this; var selection = instance.web.qweb.render("SearchView.addtodashboard.selection",{selections:this.menu_data}); From 3ce938d9054be9bd80485ce2d10b4427f7fdff43 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 20 Jun 2012 19:33:24 +0530 Subject: [PATCH 11/17] [IMP]get dashboard's in js. bzr revid: vme@tinyerp.com-20120620140324-wxp2pp2p6boct050 --- addons/web/static/src/js/search.js | 49 ++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 978ea42c8dd..58d48443e71 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1630,25 +1630,42 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ _in_drawer: true, start: function () { var self = this; + this.data_loaded = $.Deferred(); + this.menu_data =[]; this.$element .on('click', 'h4', this.proxy('show_option')) .on('submit', 'form', function (e) {e.preventDefault(); self.add_dashboard();}); - //return this.rpc('/web/searchview/get_all_dashboard', {}, function(r) {self.menu_data = r;}).pipe(this.proxy("render_data")) + return $.when(this.load_data(),this.data_loaded).pipe(self.proxy("render_data")); }, - /* - * @openerpweb.jsonrequest - def get_all_dashboard(self, req): - all_dashboard = [] - Model = req.session.model('ir.actions.act_window') - Dashboard_Menus = req.session.model('ir.values') - Dashboard_act_window = Model.search_read([('res_model','=',"board.board")],['name','id']) - for i in Dashboard_act_window: - tuple_of_dashboard = "ir.actions.act_window," + str(i["id"]) - menu_id = Dashboard_Menus.search_read([('value','=',tuple_of_dashboard)],['res_id']) - if menu_id: - all_dashboard.append({"res_id":menu_id[0]["res_id"],"name":i["name"]}) - return all_dashboard - */ + load_data:function(){ + var self = this, + ir_actions_act_window = new instance.web.Model('ir.actions.act_window',{},[['res_model','=',"board.board"],['view_id','!=',false]]) + .query(['name','id']), + map_data = function(){ + var fetch_name = arguments[0],fetch_res_id = arguments[1]; + _(fetch_res_id).each(function(res){ + var ans = _.detect(fetch_name,function(name){ return name.id == parseInt((res.value).split(",")[1]);}); + self.menu_data.push({"res_id":res.res_id,"name":ans.name}) + }); + self.data_loaded.resolve(); + }, + make_domain = function(result){ + var domain = []; + _(result).map(function(value,key){ + domain.push(["value","=","ir.actions.act_window,"+value.id]); + ((result.length)- 1 !== key)?domain.unshift("|"):false; + }) + return domain; + }; + return ir_actions_act_window._execute().then(function(result){ + if(!result.length) {self.data_loaded.resolve();return;} + var ir_value = new instance.web.Model('ir.values',{},make_domain(result)).query(['res_id','value']); + ir_value._execute().done(function(result1){ + map_data(result,result1); + }) + }); + }, + render_data: function(){ var self = this; var selection = instance.web.qweb.render("SearchView.addtodashboard.selection",{selections:this.menu_data}); @@ -1661,7 +1678,6 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ data = getParent.build_search_data(), context = new instance.web.CompoundContext(getParent.dataset.get_context() || []), domain = new instance.web.CompoundDomain(getParent.dataset.get_domain() || []); - this.$element.toggleClass('oe_opened'); _.each(data.contexts, function(x) {context.add(x);}); _.each(data.domains, function(x) {domain.add(x);}); this.rpc('/web/searchview/add_to_dashboard', { @@ -1675,6 +1691,7 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ if (r === false) { self.do_warn("Could not add filter to dashboard"); } else { + self.$element.toggleClass('oe_opened'); self.do_notify("Filter added to dashboard", ''); } }); From 53a540c57892d3a954eb43c2e97cad45b52f7261 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 20 Jun 2012 19:38:20 +0530 Subject: [PATCH 12/17] [REM]remove extra css. bzr revid: vme@tinyerp.com-20120620140820-zzo10tauy1baikxk --- addons/web/static/src/css/base.css | 10 ---------- addons/web/static/src/css/base.sass | 9 +-------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index c599d62ccba..9165811eab0 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1460,16 +1460,6 @@ display: none; margin-top: 2px; } -.openerp .oe_searchview .oe_searchview_drawer .oe_searchview_dashboard ul { - list-style: none; - padding: 0; -} -.openerp .oe_searchview .oe_searchview_drawer .oe_searchview_dashboard li { - position: relative; - list-style: none; - margin: 0; - white-space: nowrap; -} .openerp .oe_searchview .oe_searchview_drawer .oe_searchview_advanced form { display: none; margin-top: 8px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 4ee0dcf1dfb..7c2e1cbf314 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1149,14 +1149,7 @@ $colour4: #8a89ba form display: none margin-top: 2px - ul - list-style: none - padding: 0 - li - position: relative - list-style: none - margin: 0 - white-space: nowrap + .oe_searchview_advanced form display: none From f8fc7258b36f89dc7a5130a5753bef289664c33a Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 20 Jun 2012 19:49:26 +0530 Subject: [PATCH 13/17] [IMP]varibale name. bzr revid: vme@tinyerp.com-20120620141926-x4dx3krkio9fgw3k --- addons/web/static/src/js/search.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 58d48443e71..658aa04771c 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1631,7 +1631,7 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ start: function () { var self = this; this.data_loaded = $.Deferred(); - this.menu_data =[]; + this.dashboard_data =[]; this.$element .on('click', 'h4', this.proxy('show_option')) .on('submit', 'form', function (e) {e.preventDefault(); self.add_dashboard();}); @@ -1645,7 +1645,7 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ var fetch_name = arguments[0],fetch_res_id = arguments[1]; _(fetch_res_id).each(function(res){ var ans = _.detect(fetch_name,function(name){ return name.id == parseInt((res.value).split(",")[1]);}); - self.menu_data.push({"res_id":res.res_id,"name":ans.name}) + self.dashboard_data.push({"res_id":res.res_id,"name":ans.name}) }); self.data_loaded.resolve(); }, @@ -1657,18 +1657,18 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ }) return domain; }; - return ir_actions_act_window._execute().then(function(result){ - if(!result.length) {self.data_loaded.resolve();return;} - var ir_value = new instance.web.Model('ir.values',{},make_domain(result)).query(['res_id','value']); - ir_value._execute().done(function(result1){ - map_data(result,result1); + return ir_actions_act_window._execute().then(function(ir_actions_values){ + if(!ir_actions_values.length) {self.data_loaded.resolve();return;} + var ir_value = new instance.web.Model('ir.values',{},make_domain(ir_actions_values)).query(['res_id','value']); + ir_value._execute().done(function(ir_values){ + map_data(ir_actions_values,ir_values); }) }); }, render_data: function(){ var self = this; - var selection = instance.web.qweb.render("SearchView.addtodashboard.selection",{selections:this.menu_data}); + var selection = instance.web.qweb.render("SearchView.addtodashboard.selection",{selections:this.dashboard_data}); this.$element.find("input").before(selection) }, add_dashboard:function(){ From 596ebb826f981ab1077f192f6dd5aca1e2c72a22 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 20 Jun 2012 19:57:46 +0530 Subject: [PATCH 14/17] [IMP]better variable name. bzr revid: vme@tinyerp.com-20120620142746-c1k8612rkqickipw --- addons/web/static/src/js/search.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 658aa04771c..778c59289e1 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1642,10 +1642,10 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ ir_actions_act_window = new instance.web.Model('ir.actions.act_window',{},[['res_model','=',"board.board"],['view_id','!=',false]]) .query(['name','id']), map_data = function(){ - var fetch_name = arguments[0],fetch_res_id = arguments[1]; - _(fetch_res_id).each(function(res){ - var ans = _.detect(fetch_name,function(name){ return name.id == parseInt((res.value).split(",")[1]);}); - self.dashboard_data.push({"res_id":res.res_id,"name":ans.name}) + var ir_actions_values = arguments[0],ir_values = arguments[1]; + _(ir_values).each(function(res){ + var get_name = _.detect(ir_actions_values,function(name){ return name.id == parseInt((res.value).split(",")[1]);}); + self.dashboard_data.push({"res_id":res.res_id,"name":get_name.name}) }); self.data_loaded.resolve(); }, From 9c8d325d97fd84884e8eef6ff79458cb0709f3c9 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 21 Jun 2012 20:16:40 +0530 Subject: [PATCH 15/17] [IMP]get dashboard from menu also. bzr revid: vme@tinyerp.com-20120621144640-by7y68e7bx19e3f1 --- addons/web/static/src/js/search.js | 32 ++++++++++++++++++++++++++---- addons/web/static/src/xml/base.xml | 2 +- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 30c339ab279..80214fe20ba 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1635,11 +1635,12 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ this.$element .on('click', 'h4', this.proxy('show_option')) .on('submit', 'form', function (e) {e.preventDefault(); self.add_dashboard();}); - return $.when(this.load_data(),this.data_loaded).pipe(self.proxy("render_data")); + return $.when(this.load_data(),this.data_loaded).pipe(this.proxy("render_data")); }, load_data:function(){ - var self = this, - ir_actions_act_window = new instance.web.Model('ir.actions.act_window',{},[['res_model','=',"board.board"],['view_id','!=',false]]) + // get from database if dashboard position change than also works(from Reporting to else). + /*var self = this, + ir_actions_act_window = new instance.web.Model('ir.actions.act_window',{},[['res_model','=',"board.board"]]) .query(['name','id']), map_data = function(){ var ir_actions_values = arguments[0],ir_values = arguments[1]; @@ -1663,7 +1664,30 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ ir_value._execute().done(function(ir_values){ map_data(ir_actions_values,ir_values); }) - }); + });*/ + + //===============================get from instance.webclient.menu (with less rpc call) + + var dashbaord_menu = instance.webclient.menu.data.data.children,self = this, + map_data = function(result){ + _.detect(dashbaord_menu,function(dash){ + var id = _.pluck(dash.children,"id"); + var indexof = _.indexOf(id, result.res_id); + if(indexof !== -1){ + self.dashboard_data = dash.children[indexof].children + console.log(self.dashboard_data); + return; + } + self.data_loaded.resolve(); + }); + }; + return new instance.web.Model('ir.model.data') + .query(['res_id']) + .filter([['name','=','menu_reporting_dashboard']]) + .first() + .done(function (result) { + map_data(result) + }); }, render_data: function(){ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index d880293a04a..0d79aebbd04 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1397,7 +1397,7 @@ From 9154d21065a6930443a70340f613c2ae40ae1bcd Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 22 Jun 2012 10:41:16 +0530 Subject: [PATCH 16/17] [IMP]remove console bzr revid: vme@tinyerp.com-20120622051116-1uowhyk27ffh34wc --- addons/web/static/src/js/search.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 80214fe20ba..a93633cb322 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1671,14 +1671,12 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ var dashbaord_menu = instance.webclient.menu.data.data.children,self = this, map_data = function(result){ _.detect(dashbaord_menu,function(dash){ - var id = _.pluck(dash.children,"id"); - var indexof = _.indexOf(id, result.res_id); + var id = _.pluck(dash.children,"id"),indexof = _.indexOf(id, result.res_id); if(indexof !== -1){ self.dashboard_data = dash.children[indexof].children - console.log(self.dashboard_data); + self.data_loaded.resolve(); return; } - self.data_loaded.resolve(); }); }; return new instance.web.Model('ir.model.data') From 305eab618ab84dffcf3ec72f143b9319df43ceed Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Mon, 25 Jun 2012 15:31:56 +0530 Subject: [PATCH 17/17] [IMP]optimise code. bzr revid: vme@tinyerp.com-20120625100156-jx8jkfujf8nhoiy1 --- addons/web/static/src/js/search.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 84fee943514..1f98c2a1fad 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1667,11 +1667,11 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ });*/ //===============================get from instance.webclient.menu (with less rpc call) - - var dashbaord_menu = instance.webclient.menu.data.data.children,self = this, + var self = this,dashbaord_menu = instance.webclient.menu.data.data.children, + ir_model_data = new instance.web.Model('ir.model.data',{},[['name','=','menu_reporting_dashboard']]).query(['res_id']), map_data = function(result){ _.detect(dashbaord_menu,function(dash){ - var id = _.pluck(dash.children,"id"),indexof = _.indexOf(id, result.res_id); + var id = _.pluck(dash.children, "id"),indexof = _.indexOf(id, result.res_id); if(indexof !== -1){ self.dashboard_data = dash.children[indexof].children self.data_loaded.resolve(); @@ -1679,13 +1679,7 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({ } }); }; - return new instance.web.Model('ir.model.data') - .query(['res_id']) - .filter([['name','=','menu_reporting_dashboard']]) - .first() - .done(function (result) { - map_data(result) - }); + return ir_model_data._execute().done(function(result){map_data(result[0])}); }, render_data: function(){