[FIX]Web: Fixed the issue of immediate update of many2one field when many2one object...
authorMohammed Shekha (OpenERP) <msh@openerp.com>
Tue, 3 Dec 2013 12:38:56 +0000 (18:08 +0530)
committerMohammed Shekha (OpenERP) <msh@openerp.com>
Tue, 3 Dec 2013 12:38:56 +0000 (18:08 +0530)
bzr revid: msh@openerp.com-20131203123856-gce4li1igo9k1mak

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

index d497cf2..e1290de 100644 (file)
@@ -920,6 +920,15 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
      * @param {Object} id record to remove from the BDS's cache
      */
     evict_record: function (id) {
+        // Don't evict records which haven't yet been saved: there is no more
+        // recent data on the server (and there potentially isn't any data),
+        // and this breaks the assumptions of other methods (that the data
+        // for new and altered records is both in the cache and in the to_write
+        // or to_create collection)
+        if (_(this.to_create.concat(this.to_write)).find(function (record) {
+                return record.id === id; })) {
+            return;
+        }
         for(var i=0, len=this.cache.length; i<len; ++i) {
             var record = this.cache[i];
             // if record we call the button upon is in the cache
index 080cd6f..0961af0 100644 (file)
@@ -3836,6 +3836,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
         this.$el
             .off('mousedown.handleButtons')
             .on('mousedown.handleButtons', 'table button', this.proxy('_button_down'));
+        this.$el.off('mousedown.handleAnchor').on('mousedown.handleAnchor', 'div a', this.proxy('_button_down'))
         return ret;
     },
     changed_records: function () {
@@ -3995,6 +3996,12 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
         } finally {
             window.confirm = confirm;
         }
+    },
+    reload_record: function (record) {
+        // Evict record.id from cache to ensure it will be reloaded correctly
+        this.dataset.evict_record(record.get('id'));
+
+        return this._super(record);
     }
 });
 instance.web.form.One2ManyGroups = instance.web.ListView.Groups.extend({