~openerp-dev/openerp-web/7.0-bug-1092846-nwi

« back to all changes in this revision

Viewing changes to addons/web/static/src/js/data.js

  • Committer: Xavier Morel
  • Date: 2013-03-01 10:35:43 UTC
  • mfrom: (3765.1.1 7.0)
  • Revision ID: xmo@openerp.com-20130301103543-jra87w2wm417tgyc
[FIX] O2M record reloading after workflow progress

Evict record from BufferedDataSet cache as is done with button calls,
otherwise when caller reloads record (read) after having executed the
workflow action, it'll get the old one back from the BDS's cache.

Show diffs side-by-side

added added

removed removed

Lines of Context:
860
860
        }
861
861
        return completion.promise();
862
862
    },
863
 
    call_button: function (method, args) {
864
 
        var id = args[0][0], index;
 
863
    /**
 
864
     * Invalidates caching of a record in the dataset to ensure the next read
 
865
     * of that record will hit the server.
 
866
     *
 
867
     * Of use when an action is going to remote-alter a record which will then
 
868
     * need to be reloaded, e.g. action button.
 
869
     *
 
870
     * @param {Object} id record to remove from the BDS's cache
 
871
     */
 
872
    evict_record: function (id) {
865
873
        for(var i=0, len=this.cache.length; i<len; ++i) {
866
874
            var record = this.cache[i];
867
875
            // if record we call the button upon is in the cache
871
879
                break;
872
880
            }
873
881
        }
 
882
    },
 
883
    call_button: function (method, args) {
 
884
        this.evict_record(args[0][0]);
874
885
        return this._super(method, args);
875
886
    },
 
887
    exec_workflow: function (id, signal) {
 
888
        this.evict_record(id);
 
889
        return this._super(id, signal);
 
890
    },
876
891
    alter_ids: function(n_ids) {
877
892
        this._super(n_ids);
878
893
        this.trigger("dataset_changed", n_ids);