From 27463eadabb40747c53c51817cf853fdd91d192f Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 29 May 2017 15:14:49 +0200 Subject: [FIX] web: FieldMany2Many: don't save if nothing changed Suppose that there is a many2many list (non editable) in a form view. When one of the many2many subrecords is edited (from the form view in a dialog), it is saved directly when the user clicks on 'Save' in the dialog. Before this rev., if the user clicked on 'Save' in the main form view after editing a m2m subrecord, a 'write' RPC was done, whereas there were nothing left to save (as the subrecord had already been saved). --- addons/web/static/src/js/views/basic/basic_model.js | 8 ++++++++ 1 file changed, 8 insertions(+) (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 11961e6fecf..595c39103d3 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1117,6 +1117,14 @@ var BasicModel = AbstractModel.extend({ * @returns {Deferred} */ _applyX2ManyChange: function (record, fieldName, command, viewType) { + if (command.operation === 'TRIGGER_ONCHANGE') { + // the purpose of this operation is to trigger an onchange RPC, so + // there is no need to apply any change on the record (the changes + // have probably been already applied and saved, usecase: many2many + // edition in a dialog) + return $.when(); + } + var self = this; var list = this.localData[record._changes[fieldName] || record.data[fieldName]]; var field = record.fields[fieldName]; -- cgit v1.2.3