Browse Source

[FIX] fix #321, choked on cached writes

pull/327/head
Holger Brunn 8 years ago
parent
commit
d4be4768cb
  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.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)
{

Loading…
Cancel
Save