[FIX] lot of potential bugs, mainly due to quickly clicking on menu items

bzr revid: nicolas.vanhoren@openerp.com-20130227113132-m2kr9slpxp1pogaz
This commit is contained in:
niv-openerp 2013-02-27 12:31:32 +01:00
parent e141ed8546
commit 5a9bf08f46
6 changed files with 16 additions and 16 deletions

View File

@ -1032,7 +1032,7 @@ instance.web.UserMenu = instance.web.Widget.extend({
if (!self.session.uid) if (!self.session.uid)
return; return;
var func = new instance.web.Model("res.users").get_func("read"); var func = new instance.web.Model("res.users").get_func("read");
return func(self.session.uid, ["name", "company_id"]).then(function(res) { return self.alive(func(self.session.uid, ["name", "company_id"])).then(function(res) {
var topbar_name = res.name; var topbar_name = res.name;
if(instance.session.debug) if(instance.session.debug)
topbar_name = _.str.sprintf("%s (%s)", topbar_name, instance.session.db); topbar_name = _.str.sprintf("%s (%s)", topbar_name, instance.session.db);
@ -1226,7 +1226,7 @@ instance.web.WebClient = instance.web.Client.extend({
}, },
logo_edit: function(ev) { logo_edit: function(ev) {
var self = this; var self = this;
new instance.web.Model("res.users").get_func("read")(this.session.uid, ["company_id"]).then(function(res) { new self.alive(instance.web.Model("res.users").get_func("read")(this.session.uid, ["company_id"])).then(function(res) {
self.rpc("/web/action/load", { action_id: "base.action_res_company_form" }).done(function(result) { self.rpc("/web/action/load", { action_id: "base.action_res_company_form" }).done(function(result) {
result.res_id = res['company_id'][0]; result.res_id = res['company_id'][0];
result.target = "new"; result.target = "new";
@ -1247,7 +1247,7 @@ instance.web.WebClient = instance.web.Client.extend({
}, },
check_timezone: function() { check_timezone: function() {
var self = this; var self = this;
return new instance.web.Model('res.users').call('read', [[this.session.uid], ['tz_offset']]).then(function(result) { return self.alive(new instance.web.Model('res.users').call('read', [[this.session.uid], ['tz_offset']])).then(function(result) {
var user_offset = result[0]['tz_offset']; var user_offset = result[0]['tz_offset'];
var offset = -(new Date().getTimezoneOffset()); var offset = -(new Date().getTimezoneOffset());
// _.str.sprintf()'s zero front padding is buggy with signed decimals, so doing it manually // _.str.sprintf()'s zero front padding is buggy with signed decimals, so doing it manually

View File

@ -514,8 +514,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
// In case of a o2m virtual id, we should pass an empty ids list // In case of a o2m virtual id, we should pass an empty ids list
ids.push(self.datarecord.id); ids.push(self.datarecord.id);
} }
def = new instance.web.Model(self.dataset.model).call( def = self.alive(new instance.web.Model(self.dataset.model).call(
change_spec.method, [ids].concat(change_spec.args)); change_spec.method, [ids].concat(change_spec.args)));
} else { } else {
def = $.when({}); def = $.when({});
} }
@ -533,9 +533,9 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var condition = fieldname + '=' + value_; var condition = fieldname + '=' + value_;
if (value_) { if (value_) {
return new instance.web.Model('ir.values').call( return self.alive(new instance.web.Model('ir.values').call(
'get_defaults', [self.model, condition] 'get_defaults', [self.model, condition]
).then(function (results) { )).then(function (results) {
if (!results.length) { if (!results.length) {
return response; return response;
} }
@ -5367,8 +5367,8 @@ instance.web.form.FieldMonetary = instance.web.form.FieldFloat.extend({
this.set({"currency_info": null}); this.set({"currency_info": null});
return; return;
} }
return this.ci_dm.add(new instance.web.Model("res.currency").query(["symbol", "position"]) return this.ci_dm.add(self.alive(new instance.web.Model("res.currency").query(["symbol", "position"])
.filter([["id", "=", self.get("currency")]]).first()).then(function(res) { .filter([["id", "=", self.get("currency")]]).first())).then(function(res) {
self.set({"currency_info": res}); self.set({"currency_info": res});
}); });
}, },

View File

@ -1059,8 +1059,8 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
// 2. an array of ids // 2. an array of ids
ids = value; ids = value;
} }
new instance.web.Model(column.relation) self.alive(new instance.web.Model(column.relation)
.call('name_get', [ids]).done(function (names) { .call('name_get', [ids])).done(function (names) {
// FIXME: nth horrible hack in this poor listview // FIXME: nth horrible hack in this poor listview
record.set(column.id + '__display', record.set(column.id + '__display',
_(names).pluck(1).join(', ')); _(names).pluck(1).join(', '));

View File

@ -24,8 +24,8 @@ instance.web_gantt.GanttView = instance.web.View.extend({
var self = this; var self = this;
this.fields_view = fields_view_get; this.fields_view = fields_view_get;
this.$el.addClass(this.fields_view.arch.attrs['class']); this.$el.addClass(this.fields_view.arch.attrs['class']);
return new instance.web.Model(this.dataset.model) return self.alive(new instance.web.Model(this.dataset.model)
.call('fields_get').then(function (fields) { .call('fields_get')).then(function (fields) {
self.fields = fields; self.fields = fields;
self.has_been_loaded.resolve(); self.has_been_loaded.resolve();
}); });

View File

@ -246,7 +246,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
var result = []; var result = [];
var ticks = {}; var ticks = {};
return obj.call("fields_view_get", [view_id, 'graph']).then(function(tmp) { return this.alive(obj.call("fields_view_get", [view_id, 'graph']).then(function(tmp) {
view_get = tmp; view_get = tmp;
fields = view_get['fields']; fields = view_get['fields'];
var toload = _.select(group_by, function(x) { return fields[x] === undefined }); var toload = _.select(group_by, function(x) { return fields[x] === undefined });
@ -368,7 +368,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
'ticks': _.map(ticks, function(el, key) { return [el, key] }) 'ticks': _.map(ticks, function(el, key) { return [el, key] })
}; };
return res; return res;
}); }));
}, },
// Render the graph and update menu styles // Render the graph and update menu styles

View File

@ -237,7 +237,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
self.$el.toggleClass('oe_kanban_grouped_by_m2o', self.grouped_by_m2o); self.$el.toggleClass('oe_kanban_grouped_by_m2o', self.grouped_by_m2o);
var grouping_fields = self.group_by ? [self.group_by].concat(_.keys(self.aggregates)) : undefined; var grouping_fields = self.group_by ? [self.group_by].concat(_.keys(self.aggregates)) : undefined;
var grouping = new instance.web.Model(self.dataset.model, context, domain).query().group_by(grouping_fields); var grouping = new instance.web.Model(self.dataset.model, context, domain).query().group_by(grouping_fields);
return $.when(grouping).done(function(groups) { return self.alive($.when(grouping)).done(function(groups) {
if (groups) { if (groups) {
self.do_process_groups(groups); self.do_process_groups(groups);
} else { } else {