From 3d16453865a3ce5cff6323f18a880642a707e011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 10 Jul 2017 17:02:49 +0200 Subject: [FIX] web: only send fields present in view in onchange Before this commit, all x2many fields values were sent to the server in the onchange call. If a x2many field was not present in the view, then it was sent as an empty list [], which is totally wrong. --- 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 2f06168fd23..906464a5a26 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2181,7 +2181,7 @@ var BasicModel = AbstractModel.extend({ var type = record.fields[fieldName].type; var value; if (type === 'one2many' || type === 'many2many') { - if (commands[fieldName].length) { // replace localId by commands + if (commands[fieldName] && commands[fieldName].length) { // replace localId by commands changes[fieldName] = commands[fieldName]; } else { // no command -> no change for that field delete changes[fieldName]; @@ -2256,11 +2256,11 @@ var BasicModel = AbstractModel.extend({ type = fields[fieldName].type; if (type === 'many2many' || type === 'one2many') { - commands[fieldName] = []; if (!data[fieldName]) { // skip if this field is empty continue; } + commands[fieldName] = []; var list = this.localData[data[fieldName]]; if (options.changesOnly && (!list._changes || !list._changes.length)) { // if only changes are requested, skip if there is no change -- cgit v1.2.3