From 8d02a23ee96211c5fc539dc9490220a58e8467e8 Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Tue, 19 Feb 2013 15:49:40 +0530 Subject: [FIX]Fixed the issue of reload record affter callign exec_workflow for one2many dataset. bzr revid: msh@openerp.com-20130219101940-uum7iqbvvhg619uk --- addons/web/static/src/js/data.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/data.js') diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index bbff633c687..137694ee347 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -860,9 +860,8 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ } return completion.promise(); }, - call_button: function (method, args) { - var id = args[0][0], index; - for(var i=0, len=this.cache.length; i Date: Fri, 8 Mar 2013 11:40:50 +0100 Subject: added readonly fields to buffered dataset cache bzr revid: nicolas.vanhoren@openerp.com-20130308104050-uqt5qi2n9dmcd2hb --- addons/web/static/src/js/data.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'addons/web/static/src/js/data.js') diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index c5a2bd10888..5f56c4bc5f9 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -481,9 +481,12 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin, * Creates a new record in db * * @param {Object} data field values to set on the new record + * @param {Object} options Dictionary that can contain the following keys: + * - readonly_fields: Values from readonly fields that were updated by + * on_changes. Only used by the BufferedDataSet to make the o2m work correctly. * @returns {$.Deferred} */ - create: function(data) { + create: function(data, options) { return this._model.call('create', [data], {context: this.get_context()}); }, /** @@ -491,8 +494,10 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin, * * @param {Number|String} id identifier for the record to alter * @param {Object} data field values to write into the record - * @param {Function} callback function called with operation result - * @param {Function} error_callback function called in case of write error + * @param {Object} options Dictionary that can contain the following keys: + * - context: The context to use in the server-side call. + * - readonly_fields: Values from readonly fields that were updated by + * on_changes. Only used by the BufferedDataSet to make the o2m work correctly. * @returns {$.Deferred} */ write: function (id, data, options) { @@ -732,10 +737,13 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ self.last_default_get = res; }); }, - create: function(data) { - var cached = {id:_.uniqueId(this.virtual_id_prefix), values: data, - defaults: this.last_default_get}; - this.to_create.push(_.extend(_.clone(cached), {values: _.clone(cached.values)})); + create: function(data, options) { + var cached = { + id:_.uniqueId(this.virtual_id_prefix), + values: _.extend({}, data, (options || {}).readonly_fields || {}), + defaults: this.last_default_get + }; + this.to_create.push(_.extend(_.clone(cached), {values: _.clone(data)})); this.cache.push(cached); return $.Deferred().resolve(cached.id).promise(); }, @@ -762,7 +770,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ cached = {id: id, values: {}}; this.cache.push(cached); } - $.extend(cached.values, record.values); + $.extend(cached.values, _.extend({}, record.values, (options || {}).readonly_fields || {})); if (dirty) this.trigger("dataset_changed", id, data, options); return $.Deferred().resolve(true).promise(); @@ -918,9 +926,9 @@ instance.web.ProxyDataSet = instance.web.DataSetSearch.extend({ return this._super.apply(this, arguments); } }, - create: function(data) { + create: function(data, options) { if (this.create_function) { - return this.create_function(data, this._super); + return this.create_function(data, options, this._super); } else { return this._super.apply(this, arguments); } -- cgit v1.2.3