From d4be4768cb97fc3b8893df03999fe75555151703 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 17 Mar 2016 11:05:13 +0100 Subject: [PATCH] [FIX] fix #321, choked on cached writes --- .../src/js/web_widget_x2many_2d_matrix.js | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js b/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js index 438d52b7..4dbcb4cc 100644 --- a/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js +++ b/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js @@ -93,7 +93,35 @@ openerp.web_widget_x2many_2d_matrix = function(instance) self.is_numeric = fields[self.field_value].type == 'float'; self.show_row_totals &= self.is_numeric; self.show_column_totals &= self.is_numeric; - }).then(function() + }) + // if there are cached writes on the parent dataset, read below + // only returns the written data, which is not enough to properly + // set up our data structure. Read those ids here and patch the + // cache + .then(function() + { + var ids_written = _.map( + self.dataset.to_write, function(x) { return x.id }); + if(!ids_written.length) + { + return; + } + return (new instance.web.Query(self.dataset._model)) + .filter([['id', 'in', ids_written]]) + .all() + .then(function(rows) + { + _.each(rows, function(row) + { + var cache = _.find( + self.dataset.cache, + function(x) { return x.id == row.id } + ); + _.extend(cache.values, row, _.clone(cache.values)); + }) + }) + }) + .then(function() { return self.dataset.read_ids(self.dataset.ids).then(function(rows) {