From c587c0029b3211708f371b13c20b3efc7b6c9b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Fri, 18 May 2018 15:18:24 +0200 Subject: [FIX] web: only abandon records on discard without savepoint Revision on https://github.com/odoo/odoo/commit/9a9da5763b38a3bce54e9c4870af0032e38cacc3 The intent of the commit above was to no abandon records in a list on discard when these records have been created from a `default_get`. Also, the `default_get` may also perform an `onchange` that could create more records. The records from this `onchange` must also be included in the "do not abandon" rule. However, the rule was too relax, so that any following `onchanges` from a user interaction was also considered into this rule. As a result, it was not possible to abandon such records. With this fix, we restrict the rule to `default_get` (already the case) and only the `onchange` right after a `default_get`. Any record created on an `onchange` from a user interaction after a `default_get` should be abandoned on discard. Representation of creating the list: savepoint |----------|-----------|-------||--------|-------> create default_get onchange1 onchange2 record in the list is created by default_get or onchange1 => do not abandon on discard record in the list is created by onchange2 => abandon on discard --- addons/web/static/src/js/views/basic/basic_model.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 60c167ddfd1..36e9652dd9b 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1542,8 +1542,10 @@ var BasicModel = AbstractModel.extend({ rec = self._makeDataPoint(params); list._cache[rec.res_id] = rec.id; } - - rec._noAbandon = true; + // Do not abandon the record if it has been created + // from `default_get`. The list has a savepoint only + // after having fully executed `default_get`. + rec._noAbandon = !list._savePoint; list._changes.push({operation: 'ADD', id: rec.id}); if (command[0] === 1) { list._changes.push({operation: 'UPDATE', id: rec.id}); -- cgit v1.2.3