From 64a9398fb385896cafe7725d7361e6131561f606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 6 Apr 2017 16:51:26 +0200 Subject: [FIX] web: fix corrupt datapoint in basic model When saving a new record, with the option reload=false, a datapoint in the basic model could be left in a wrong state: the x2many fields were deleted, with all the changes, but the values in the data key were still null, which means that the x2many field has no valid corresponding datapoint, as far as the basicmodel can see. So, with this commit, we make sure to push the changes into the data, so the datapoint is in a proper clean state. --- addons/web/static/src/js/views/basic/basic_model.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index d904f8f1ec7..1d511b1eb34 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -640,10 +640,15 @@ var BasicModel = AbstractModel.extend({ record.res_ids.push(id); record.count++; } - // erase changes as they have been applied - record._changes = {}; - - return shouldReload ? self._fetchRecord(record) : false; + if (shouldReload) { + // erase changes as they have been applied + record._changes = {}; + return self._fetchRecord(record); + } else { + _.extend(record.data, record._changes); + record._changes = {}; + return false; + } }); } else { return $.when(record_id); -- cgit v1.2.3