From 0f9e986c468702ebe55860895ef8d8b84c90a48c Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 16 May 2017 15:02:58 +0200 Subject: [FIX] web: BasicModel: discard changes when reloading ... from a new record. Steps to reproduce the issue: - go to a multi-record view (e.g. list) of basically any model - click on 'Create' -> it opens a form view in edit mode - click on 'Discard' -> it goes back to the list - click on an existing record -> it should open the selected record in readonly. However, it didn't display the data of the selected record, but the default data of a new record (the result of a default_get). This was because the changes weren't properly discarded when reloading from a new record (it rather restored the record to its initial state, i.e. to the result of the default_get). --- addons/web/static/src/js/views/basic/basic_model.js | 4 ++-- 1 file changed, 2 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 5e5b36472f5..a55d2b2723b 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -228,7 +228,7 @@ var BasicModel = AbstractModel.extend({ options = options || {}; var element = this.localData[id]; var isNew = this.isNew(id); - var rollback = options.rollback || isNew; + var rollback = 'rollback' in options ? options.rollback : isNew; this._visitChildren(element, function (elem) { if (rollback && elem._savePoint) { if (elem._savePoint instanceof Array) { @@ -644,7 +644,7 @@ var BasicModel = AbstractModel.extend({ return this._makeDefaultRecord(element.model, params); } if (!options.keepChanges) { - this.discardChanges(id); + this.discardChanges(id, {rollback: false}); } } -- cgit v1.2.3