From 9ee2c1d66c13c50366503df087ac1c8ce649e037 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 7 Dec 2011 13:00:45 +0530 Subject: [PATCH 1/5] [fix]disable create button. lp bug: https://launchpad.net/bugs/900805 fixed bzr revid: vme@tinyerp.com-20111207073045-67n2zaizvyulu1lp --- addons/web/static/src/js/view_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index de7dd1a77f5..626b7af6411 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -212,7 +212,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# this.$element.find('.oe-list-add') .click(this.do_add_record) - .attr('disabled', grouped && this.options.editable); + .attr('disabled', grouped && !this.options.editable); this.$element.find('.oe-list-delete') .attr('disabled', true) .click(this.do_delete_selected); From c4655794a1c688e100e85957f2940189f4d1e3a9 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 7 Dec 2011 18:22:00 +0530 Subject: [PATCH 2/5] [fix]fix code. bzr revid: vme@tinyerp.com-20111207125200-qhcbvs557cjerg4x --- addons/web/static/src/js/views.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index db64865c266..93cf029731c 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -455,6 +455,9 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner }, on_mode_switch: function (view_type) { var self = this; + if (!_.include(_.pluck(this.views_src,"view_type"),view_type)) + return; + return $.when( this._super(view_type), this.shortcut_check(this.views[view_type]) From b93b2f402587f30020675e7ee492bf62a0594611 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 8 Dec 2011 11:29:09 +0530 Subject: [PATCH 3/5] [fix]fix code according to suggestion. bzr revid: vme@tinyerp.com-20111208055909-coh3vxbbqxo7j250 --- addons/web/static/src/js/view_list.js | 2 +- addons/web/static/src/js/views.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 0025bd6e83c..6e62955f0b1 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -212,7 +212,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# this.$element.find('.oe-list-add') .click(this.do_add_record) - .attr('disabled', grouped && !this.options.editable); + .attr('disabled', grouped && this.options.editable); this.$element.find('.oe-list-delete') .attr('disabled', true) .click(this.do_delete_selected); diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index f723c54da5d..2e595146d0d 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -243,12 +243,16 @@ session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.View */ on_mode_switch: function(view_type, no_store) { var self = this, + view = this.views[view_type], view_promise; + if(!view) + return $.Deferred().reject(); + if (!no_store) { this.views_history.push(view_type); } this.active_view = view_type; - var view = this.views[view_type]; + if (!view.controller) { // Lazy loading of views var controllerclass = this.registry.get_object(view_type); @@ -471,8 +475,8 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner }, on_mode_switch: function (view_type, no_store) { var self = this; - if (!_.include(_.pluck(this.views_src,"view_type"),view_type)) - return; + if (!(view_type in this.views)) + return $.Deferred().reject(); var switched = $.when(this._super(view_type, no_store)).then(function () { self.$element.find('.oe-view-manager-logs:first') From a84247b3f29df1b0464cc25a9b1f794ec8b196e4 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 9 Dec 2011 11:21:46 +0530 Subject: [PATCH 4/5] [IMP]improved code. bzr revid: vme@tinyerp.com-20111209055146-sbj4z1fb203yknop --- addons/web/static/src/js/views.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 2e595146d0d..5d55fffd281 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -475,17 +475,15 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner }, on_mode_switch: function (view_type, no_store) { var self = this; - if (!(view_type in this.views)) - return $.Deferred().reject(); var switched = $.when(this._super(view_type, no_store)).then(function () { self.$element.find('.oe-view-manager-logs:first') .addClass('oe-folded').removeClass('oe-has-more') .find('ul').empty(); + self.shortcut_check(self.views[view_type]) }); return $.when( - switched, - this.shortcut_check(this.views[view_type]) + switched ).then(function() { var controller = self.views[self.active_view].controller, fvg = controller.fields_view, From 76ec7bea0598373d26f3e80d805b9c46a78585eb Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 9 Dec 2011 19:18:09 +0530 Subject: [PATCH 5/5] [IMP]used pipe instead of then, bzr revid: vme@tinyerp.com-20111209134809-l7rh0th8lgk5gz2i --- addons/web/static/src/js/views.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 0d8621ddd49..2237665a10d 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -498,16 +498,16 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner }, on_mode_switch: function (view_type, no_store) { var self = this; - - var switched = $.when(this._super(view_type, no_store)).then(function () { + + var switched = $.when(this._super(view_type, no_store)).pipe(function () { + self.shortcut_check(self.views[view_type]); self.$element.find('.oe-view-manager-logs:first') .addClass('oe-folded').removeClass('oe-has-more') .find('ul').empty(); - self.shortcut_check(self.views[view_type]); }); return $.when( switched - ).then(function() { + ).pipe(function() { var controller = self.views[self.active_view].controller, fvg = controller.fields_view, view_id = (fvg && fvg.view_id) || '--';