summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2012-08-06 17:00:02 +0200
committerXavier Morel <xmo@openerp.com>2012-08-06 17:00:02 +0200
commitd8e2bec1580f8a4635f9cfa52be5001a777cd35b (patch)
tree61fc581af782ee2f199e5f61da85492ae4074988 /addons/web/static/src
parent3f955f05250614174be25d190c7d988d0a69b9aa (diff)
[FIX] state of editor after cancelled cancel() (haha), handling of a record being edited during o2m deletion
bzr revid: xmo@openerp.com-20120806150002-45c8mjq9dk5hck7y
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/view_form.js28
-rw-r--r--addons/web/static/src/js/view_list_editable.js13
2 files changed, 27 insertions, 14 deletions
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 1f22529ba2a..cc92244ce81 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -3483,14 +3483,26 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
this._super.apply(this, arguments);
},
do_delete: function (ids) {
- // wheeee
- var confirm = window.confirm;
- window.confirm = function () { return true; };
- try {
- return this._super(ids);
- } finally {
- window.confirm = confirm;
- }
+ 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);
+ }
+ return next.pipe(function () {
+ // wheeee
+ var confirm = window.confirm;
+ window.confirm = function () { return true; };
+ try {
+ return _super.call(self, ids);
+ } finally {
+ window.confirm = confirm;
+ }
+ });
}
});
instance.web.form.One2ManyList = instance.web.ListView.List.extend({
diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js
index 038593c54c3..3a574c30e56 100644
--- a/addons/web/static/src/js/view_list_editable.js
+++ b/addons/web/static/src/js/view_list_editable.js
@@ -281,16 +281,17 @@ openerp.web.list_editable = function (instance) {
});
},
/**
+ * @param {Boolean} [force=false] discards the data even if the form has been edited
* @return {jQuery.Deferred}
*/
- cancel_edition: function () {
+ cancel_edition: function (force) {
var self = this;
return this.with_event('cancel', {
editor: this.editor,
form: this.editor.form,
cancel: false
}, function () {
- return this.editor.cancel().pipe(function (attrs) {
+ return this.editor.cancel(force).pipe(function (attrs) {
if (attrs.id) {
var record = self.records.get(attrs.id);
if (!record) {
@@ -717,13 +718,13 @@ openerp.web.list_editable = function (instance) {
return self.cancel();
});
},
- cancel: function () {
- var record = this.record;
- this.record = null;
- if (!this.form.can_be_discarded()) {
+ cancel: function (force) {
+ if (!(force || this.form.can_be_discarded())) {
return $.Deferred().reject({
message: "The form's data can not be discarded"}).promise();
}
+ var record = this.record;
+ this.record = null;
this.form.do_hide();
return $.when(record);
}