[FIX] Fixed on_loaded in Menu and Search.

bzr revid: vta@openerp.com-20121018085028-d0ww48el2jwmtcpg
This commit is contained in:
vta vta@openerp.com 2012-10-18 10:50:28 +02:00
parent bd049325f0
commit 8b4580ea86
3 changed files with 16 additions and 9 deletions

View File

@ -701,9 +701,12 @@ instance.web.Menu = instance.web.Widget.extend({
return this.do_reload();
},
do_reload: function() {
return this.rpc("/web/menu/load", {}).then(this.on_loaded);
var self = this;
return this.rpc("/web/menu/load", {}).then(function(r) {
self.menu_loaded(r);
});
},
on_loaded: function(data) {
menu_loaded: function(data) {
var self = this;
this.data = data;
this.renderElement();
@ -720,6 +723,7 @@ instance.web.Menu = instance.web.Widget.extend({
if (self.current_menu) {
self.open_menu(self.current_menu);
}
this.trigger('menu_loaded', data);
this.has_been_loaded.resolve();
},
limit_entries: function() {

View File

@ -324,8 +324,9 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
context: this.dataset.get_context() });
$.when(load_view)
.pipe(this.on_loaded)
.fail(function () {
.pipe(function(r) {
self.search_view_loaded(r)
}).fail(function () {
self.ready.reject.apply(null, arguments);
});
}
@ -645,7 +646,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
(new instance.web.search.Advanced(this));
},
on_loaded: function(data) {
search_view_loaded: function(data) {
var self = this;
this.fields_view = data.fields_view;
if (data.fields_view.type !== 'search' ||
@ -654,7 +655,6 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
"Got non-search view after asking for a search view: type %s, arch root %s",
data.fields_view.type, data.fields_view.arch.tag));
}
this.make_widgets(
data.fields_view['arch'].children,
data.fields_view.fields);
@ -671,9 +671,12 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
'facet_for_defaults', this.defaults)).then(function () {
self.query.reset(_(arguments).compact(), {preventSearch: true});
});
self.trigger("search_view_load");
return $.when(drawer_started, defaults_fetched)
.then(function () { self.ready.resolve(); })
.then(function () {
self.trigger("search_view_loaded", data);
self.ready.resolve();
});
},
/**
* Handle event when the user make a selection in the filters management select box.

View File

@ -4476,7 +4476,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
self.do_search(domains.concat([self.domain]), contexts.concat(self.context), groupbys);
}
});
this.searchview.on("search_view_load",self,function () {
this.searchview.on("search_view_loaded", self, function() {
self.view_list = new instance.web.form.SelectCreateListView(self,
self.dataset, false,
_.extend({'deletable': false,