[FIX] correctly handle case of deleting-an-o2m-line-being-edited
move special case in o2m listview to main editable and expand to correctly fit edition cases, not just work in case of creation issue: if a row being edited is deleted in an o2m, the form will be blurred and try cancelling/saving the edition and reloading the row, but this will only happen *after* the record/row/whatever has been "deleted" and (amongst other things) removed from the buffered o2m cache, leading to a tentative read on the server side (usually with a local id which doesn't even make sense) and thus an error. Intercept the deletion signal to cancel the edition immediately and only let the deletion through after the edition has successfully been canceled. bzr revid: xmo@openerp.com-20121116164416-8kr39t6jtqy2s3jc
This commit is contained in:
parent
4a454397f8
commit
86842fe9c8
|
@ -3837,26 +3837,13 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
|
|||
this._super.apply(this, arguments);
|
||||
},
|
||||
do_delete: function (ids) {
|
||||
var self = this;
|
||||
var next = $.when();
|
||||
var _super = this._super;
|
||||
// handle deletion of an item which does not exist
|
||||
// TODO: better handle that in the editable list?
|
||||
var false_id_index = _(ids).indexOf(false);
|
||||
if (false_id_index !== -1) {
|
||||
ids.splice(false_id_index, 1);
|
||||
next = this.cancel_edition(true);
|
||||
var confirm = window.confirm;
|
||||
window.confirm = function () { return true; };
|
||||
try {
|
||||
return this._super(ids);
|
||||
} finally {
|
||||
window.confirm = confirm;
|
||||
}
|
||||
return next.then(function () {
|
||||
// wheeee
|
||||
var confirm = window.confirm;
|
||||
window.confirm = function () { return true; };
|
||||
try {
|
||||
return _super.call(self, ids);
|
||||
} finally {
|
||||
window.confirm = confirm;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
instance.web.form.One2ManyGroups = instance.web.ListView.Groups.extend({
|
||||
|
|
|
@ -77,6 +77,15 @@ openerp.web.list_editable = function (instance) {
|
|||
do_edit: function (index, id, dataset) {
|
||||
_.extend(this.dataset, dataset);
|
||||
},
|
||||
do_delete: function (ids) {
|
||||
var _super = this._super.bind(this);
|
||||
var next = this.editor.is_editing()
|
||||
? this.cancel_edition(true)
|
||||
: $.when();
|
||||
return next.then(function () {
|
||||
return _super(ids);
|
||||
});
|
||||
},
|
||||
editable: function () {
|
||||
return this.fields_view.arch.attrs.editable
|
||||
|| this._context_editable
|
||||
|
|
Loading…
Reference in New Issue