[FIX] web: reload after wizard when record has been removed cause exception
If an action unlink the current records (e.g. unreconcile on account.move.reconcile), trigger history_back to avoid errors when trying to reload inexistant record (opw 607883) This is a partial backport of saas-4 code (revc0db6ae
,162ad1c
) and should not be forward ported.
This commit is contained in:
parent
8320f01fef
commit
680f9554b4
|
@ -101,9 +101,6 @@ instance.web.Dialog = instance.web.Widget.extend({
|
|||
autoOpen: false,
|
||||
position: [false, 40],
|
||||
buttons: null,
|
||||
beforeClose: function () {
|
||||
self.trigger("closing");
|
||||
},
|
||||
resizeStop: function() {
|
||||
self.trigger("resized");
|
||||
},
|
||||
|
@ -204,8 +201,9 @@ instance.web.Dialog = instance.web.Widget.extend({
|
|||
/**
|
||||
Closes the popup, if destroy_on_close was passed to the constructor, it is also destroyed.
|
||||
*/
|
||||
close: function() {
|
||||
close: function(reason) {
|
||||
if (this.dialog_inited && this.$el.is(":data(dialog)")) {
|
||||
this.trigger("closing", reason);
|
||||
this.$el.dialog('close');
|
||||
}
|
||||
},
|
||||
|
@ -221,14 +219,14 @@ instance.web.Dialog = instance.web.Widget.extend({
|
|||
/**
|
||||
Destroys the popup, also closes it.
|
||||
*/
|
||||
destroy: function () {
|
||||
destroy: function (reason) {
|
||||
this.$buttons.remove();
|
||||
_.each(this.getChildren(), function(el) {
|
||||
el.destroy();
|
||||
});
|
||||
if (! this.__tmp_dialog_closing) {
|
||||
this.__tmp_dialog_destroying = true;
|
||||
this.close();
|
||||
this.close(reason);
|
||||
this.__tmp_dialog_destroying = undefined;
|
||||
}
|
||||
if (this.dialog_inited && !this.isDestroyed() && this.$el.is(":data(dialog)")) {
|
||||
|
|
|
@ -957,14 +957,20 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
|||
} else {
|
||||
var fields = _.keys(self.fields_view.fields);
|
||||
fields.push('display_name');
|
||||
return self.dataset.read_index(fields,
|
||||
// Use of search_read instead of read to check if we can still read the record (security rules)
|
||||
return self.dataset.call('search_read', [[['id', '=', self.dataset.ids[self.dataset.index]]], fields],
|
||||
{
|
||||
context: {
|
||||
'bin_size': true,
|
||||
'future_display_name': true
|
||||
}
|
||||
}).then(function(r) {
|
||||
self.trigger('load_record', r);
|
||||
if (_.isEmpty(r)){
|
||||
self.do_action('history_back');
|
||||
}
|
||||
else{
|
||||
self.trigger('load_record', r[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1972,8 +1978,10 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
|
|||
|
||||
return this.view.do_execute_action(
|
||||
_.extend({}, this.node.attrs, {context: context}),
|
||||
this.view.dataset, this.view.datarecord.id, function () {
|
||||
self.view.recursive_reload();
|
||||
this.view.dataset, this.view.datarecord.id, function (reason) {
|
||||
if (!_.isObject(reason)) {
|
||||
self.view.recursive_reload();
|
||||
}
|
||||
});
|
||||
},
|
||||
check_disable: function() {
|
||||
|
|
|
@ -528,13 +528,14 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
|||
},
|
||||
reload_record: function (record) {
|
||||
var self = this;
|
||||
return this.dataset.read_ids(
|
||||
[record.get('id')],
|
||||
// Use of search_read instead of read to check if we can still read the record (security rules)
|
||||
return this.dataset.call('search_read', [
|
||||
[['id', '=', record.get('id')]],
|
||||
_.pluck(_(this.columns).filter(function (r) {
|
||||
return r.tag === 'field';
|
||||
}), 'name')
|
||||
}), 'name')]
|
||||
).done(function (records) {
|
||||
var values = records[0];
|
||||
var values = _.isEmpty(records) ? undefined : records[0];
|
||||
if (!values) {
|
||||
self.records.remove(record);
|
||||
return;
|
||||
|
|
|
@ -22,9 +22,9 @@ instance.web.ActionManager = instance.web.Widget.extend({
|
|||
this._super.apply(this, arguments);
|
||||
this.$el.on('click', 'a.oe_breadcrumb_item', this.on_breadcrumb_clicked);
|
||||
},
|
||||
dialog_stop: function () {
|
||||
dialog_stop: function (reason) {
|
||||
if (this.dialog) {
|
||||
this.dialog.destroy();
|
||||
this.dialog.destroy(reason);
|
||||
}
|
||||
this.dialog = null;
|
||||
},
|
||||
|
@ -376,7 +376,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
|
|||
if (this.dialog_widget && !this.dialog_widget.isDestroyed()) {
|
||||
this.dialog_widget.destroy();
|
||||
}
|
||||
this.dialog_stop();
|
||||
this.dialog_stop(executor.action);
|
||||
this.dialog = new instance.web.Dialog(this, {
|
||||
dialogClass: executor.klass,
|
||||
});
|
||||
|
@ -394,7 +394,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
|
|||
this.dialog.open();
|
||||
return initialized;
|
||||
} else {
|
||||
this.dialog_stop();
|
||||
this.dialog_stop(executor.action);
|
||||
this.inner_action = executor.action;
|
||||
this.inner_widget = widget;
|
||||
executor.post_process(widget);
|
||||
|
|
Loading…
Reference in New Issue