[FIX] cancel list edition on search
authorXavier Morel <xmo@openerp.com>
Mon, 10 Dec 2012 10:09:14 +0000 (11:09 +0100)
committerXavier Morel <xmo@openerp.com>
Mon, 10 Dec 2012 10:09:14 +0000 (11:09 +0100)
Otherwise, if a search is performed while creating or editing a line
(e.g. in logged calls, create a line without saving then try to apply
a filter) the edition section (and new line) disappears but the list
remains in "edition" mode (e.g. save/discard button) even though
edition data is missing (trying to save or discard will error out).

bzr revid: xmo@openerp.com-20121210100914-delia5bhmtgrujpu

addons/web/static/src/js/view_list_editable.js

index 83a7efa..efc442d 100644 (file)
@@ -105,8 +105,15 @@ openerp.web.list_editable = function (instance) {
          * Replace do_search to handle editability process
          */
         do_search: function(domain, context, group_by) {
-            this._context_editable = !!context.set_editable;
-            this._super.apply(this, arguments);
+            var self=this, _super = self._super, args=arguments;
+            var ready = this.editor.is_editing()
+                    ? this.cancel_edition(true)
+                    : $.when();
+
+            return ready.then(function () {
+                self._context_editable = !!context.set_editable;
+                return _super.apply(self, args);
+            });
         },
         /**
          * Replace do_add_record to handle editability (and adding new record