Browse Source

Merge pull request #327 from hbrunn/8.0-issue321

[FIX] fix #321, choked on cached writes
pull/339/head
Guewen Baconnier 9 years ago
parent
commit
727e4dfce4
  1. 30
      web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

30
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.is_numeric = fields[self.field_value].type == 'float';
self.show_row_totals &= self.is_numeric; self.show_row_totals &= self.is_numeric;
self.show_column_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) return self.dataset.read_ids(self.dataset.ids).then(function(rows)
{ {

Loading…
Cancel
Save