Solved problems with switch_mode
bzr revid: nicolas.vanhoren@openerp.com-20120725141832-4zqw6g0zf9m4hfro
This commit is contained in:
parent
31621f412a
commit
fe8b2937c9
|
@ -63,6 +63,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
* @property {instance.web.Registry} registry=instance.web.form.widgets widgets registry for this form view instance
|
* @property {instance.web.Registry} registry=instance.web.form.widgets widgets registry for this form view instance
|
||||||
*/
|
*/
|
||||||
init: function(parent, dataset, view_id, options) {
|
init: function(parent, dataset, view_id, options) {
|
||||||
|
var self = this;
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.set_default_options(options);
|
this.set_default_options(options);
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
|
@ -92,6 +93,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
this.qweb = null; // A QWeb instance will be created if the view is a QWeb template
|
this.qweb = null; // A QWeb instance will be created if the view is a QWeb template
|
||||||
this.on("change:mode", this, this._check_mode);
|
this.on("change:mode", this, this._check_mode);
|
||||||
this.set({mode: "view"});
|
this.set({mode: "view"});
|
||||||
|
this.has_been_loaded.then(function() {
|
||||||
|
self.switch_mode();
|
||||||
|
self.on("change:actual_mode", self, self.switch_mode);
|
||||||
|
self.set({mode: self.options.initial_mode});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
_.each(this.get_widgets(), function(w) {
|
_.each(this.get_widgets(), function(w) {
|
||||||
|
@ -104,12 +110,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
/**
|
/**
|
||||||
* Reactualize actual_mode.
|
* Reactualize actual_mode.
|
||||||
*/
|
*/
|
||||||
_check_mode: function(options) {
|
_check_mode: function() {
|
||||||
options = options || {};
|
|
||||||
var mode = this.get("mode");
|
var mode = this.get("mode");
|
||||||
if (mode === "edit" && ! this.datarecord.id)
|
if (mode === "edit" && ! this.datarecord.id)
|
||||||
mode = "create";
|
mode = "create";
|
||||||
this.set({actual_mode: mode}, options);
|
this.set({actual_mode: mode});
|
||||||
},
|
},
|
||||||
on_loaded: function(data) {
|
on_loaded: function(data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -169,10 +174,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
{ label: _t('Set Default'), callback: function (item) { self.open_defaults_dialog(); } },
|
{ label: _t('Set Default'), callback: function (item) { self.open_defaults_dialog(); } },
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
this.on("change:actual_mode", this, this.switch_mode);
|
|
||||||
this.set({mode: this.options.initial_mode}, {silent: true});
|
|
||||||
this._check_mode({silent: true});
|
|
||||||
this.switch_mode();
|
|
||||||
this.has_been_loaded.resolve();
|
this.has_been_loaded.resolve();
|
||||||
return $.when();
|
return $.when();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue