[ADD] reimplement o2m's cancel-on-blur when no alteration has been done by the user...
authorXavier Morel <xmo@openerp.com>
Wed, 18 Jul 2012 13:46:07 +0000 (15:46 +0200)
committerXavier Morel <xmo@openerp.com>
Wed, 18 Jul 2012 13:46:07 +0000 (15:46 +0200)
bzr revid: xmo@openerp.com-20120718134607-bukj6c5lysmqeer3

addons/web/static/src/js/view_form.js

index 948b3a7..92faa3d 100644 (file)
@@ -3331,13 +3331,20 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
     /**
      * Handles blurring of the nested form (saves the currently edited row),
      * unless the flag to ignore the event is set to ``true``
+     *
+     * Makes the internal form go away
      */
     _on_form_blur: function () {
         if (this.__ignore_blur) {
             this.__ignore_blur = false;
             return;
         }
-        this.save_edition();
+        // FIXME: why isn't there an API for this?
+        if (this.editor.form.$element.hasClass('oe_form_dirty')) {
+            this.save_edition();
+            return;
+        }
+        this.cancel_edition();
     },
     keyup_ENTER: function () {
         // blurring caused by hitting the [Return] key, should skip the