From 6397ce7eb0c4ad912259ab6d6ee3a9fbf16d0c64 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 4 Apr 2018 13:28:35 +0200 Subject: [FIX] web: loss of context when duplicating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create a vendor bill, save and validate - Duplicate the bill, save - Click on "Create" A customer invoice is created, while the user expects a vendor bill. After duplication, the new record is loaded but the context is lost. Since the default value for the invoice type is based on the context key `type`, a loss of context leads to an incorrect invoice type. opw-1826453 Co-authored-by: Géry Debongnie --- addons/web/static/src/js/views/basic/basic_model.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (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 11e2347eba7..d7d91a65405 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -375,11 +375,12 @@ var BasicModel = AbstractModel.extend({ duplicateRecord: function (recordID) { var self = this; var record = this.localData[recordID]; + var context = this._getContext(record); return this._rpc({ model: record.model, method: 'copy', args: [record.data.id], - context: this._getContext(record), + context: context, }) .then(function (res_id) { var index = record.res_ids.indexOf(record.res_id); @@ -391,6 +392,7 @@ var BasicModel = AbstractModel.extend({ res_id: res_id, res_ids: record.res_ids.slice(0), viewType: record.viewType, + context: context, }); }); }, -- cgit v1.2.3