From 2771b23a35c27165b54904a9e433202a5cd226af Mon Sep 17 00:00:00 2001 From: kujiu Date: Tue, 25 Jul 2017 13:43:37 +0200 Subject: [FIX] web: do not delete records for one2many with widget=many2many Some one2many fields are called with a many2many widget to unlink records instead of delete them. But this behavior was modified with the new views and the records were deleted anyway. In this commit, we restore the previous behavior, and create a FORGET command in basic model to do that. Note that the widget='many2many' is a hack, and a better way to accomplish this is to use a new custom option. But this would be a fix for master (PR #18413) --- addons/web/static/tests/views/basic_model_tests.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'addons/web/static/tests/views/basic_model_tests.js') diff --git a/addons/web/static/tests/views/basic_model_tests.js b/addons/web/static/tests/views/basic_model_tests.js index 7f7547262da..9e8e64edde6 100644 --- a/addons/web/static/tests/views/basic_model_tests.js +++ b/addons/web/static/tests/views/basic_model_tests.js @@ -361,27 +361,27 @@ QUnit.module('Views', { assert.strictEqual(record.data.product_ids.count, 2, "there should be two records in the relation"); - // trigger a 'REMOVE' command on the existing record + // trigger a 'DELETE' command on the existing record var existingRecordID = record.data.product_ids.data[0].id; - model.notifyChanges(resultID, {product_ids: {operation: 'REMOVE', ids: [existingRecordID]}}); + model.notifyChanges(resultID, {product_ids: {operation: 'DELETE', ids: [existingRecordID]}}); assert.deepEqual(model.localData[x2mListID]._changes, [{ operation: 'ADD', id: newRecordID, }, { operation: 'UPDATE', id: newRecordID, }, { - operation: 'REMOVE', id: existingRecordID, + operation: 'DELETE', id: existingRecordID, }], "_changes should be correct"); record = model.get(resultID); assert.strictEqual(record.data.product_ids.count, 1, "there should be one record in the relation"); - // trigger a 'REMOVE' command on the new record - model.notifyChanges(resultID, {product_ids: {operation: 'REMOVE', ids: [newRecordID]}}); + // trigger a 'DELETE' command on the new record + model.notifyChanges(resultID, {product_ids: {operation: 'DELETE', ids: [newRecordID]}}); assert.deepEqual(model.localData[x2mListID]._changes, [{ - operation: 'REMOVE', id: existingRecordID, + operation: 'DELETE', id: existingRecordID, }], "_changes should be correct"); record = model.get(resultID); assert.strictEqual(record.data.product_ids.count, 0, @@ -827,7 +827,7 @@ QUnit.module('Views', { assert.ok(_.isObject(category_value), "category field should have been fetched"); assert.strictEqual(category_value.data.length, 1, "category field should contain one record"); model.notifyChanges(resultID, {category: { - operation: 'REMOVE', + operation: 'DELETE', ids: [category_value.data[0].id], }}); assert.ok(model.isDirty(resultID), "record should be considered dirty"); -- cgit v1.2.3