[FIX] FormView#do_show() uses has_been_loaded deferred

bzr revid: fme@openerp.com-20111219163051-2gt4p3a5voplysog
This commit is contained in:
Fabien Meghazi 2011-12-19 17:30:51 +01:00
parent f295808ff1
commit 7f9b7b1f66
2 changed files with 16 additions and 13 deletions

View File

@ -15,7 +15,7 @@
"static/lib/datejs/parser.js", "static/lib/datejs/parser.js",
"static/lib/datejs/sugarpak.js", "static/lib/datejs/sugarpak.js",
"static/lib/datejs/extras.js", "static/lib/datejs/extras.js",
"static/lib/jquery/jquery-1.6.4.js", "static/lib/jquery/jquery-1.7.1.js",
"static/lib/jquery.MD5/jquery.md5.js", "static/lib/jquery.MD5/jquery.md5.js",
"static/lib/jquery.form/jquery.form.js", "static/lib/jquery.form/jquery.form.js",
"static/lib/jquery.validate/jquery.validate.js", "static/lib/jquery.validate/jquery.validate.js",

View File

@ -132,18 +132,21 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
}, },
do_show: function () { do_show: function () {
var promise; var self = this,
if (this.dataset.index === null) { deferred = $.Deferred();
// null index means we should start a new record this.has_been_loaded.then(function() {
promise = this.on_button_new(); if (self.dataset.index === null) {
} else { // null index means we should start a new record
promise = this.dataset.read_index(_.keys(this.fields_view.fields)).pipe(this.on_record_loaded); deferred.pipe(self.on_button_new());
} } else {
this.$element.show(); deferred.pipe(self.dataset.read_index(_.keys(self.fields_view.fields)).pipe(self.on_record_loaded));
if (this.sidebar) { }
this.sidebar.$element.show(); self.$element.show();
} if (self.sidebar) {
return promise; self.sidebar.$element.show();
}
});
return deferred;
}, },
do_hide: function () { do_hide: function () {
this._super(); this._super();