summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2019-09-06 09:15:45 +0000
committerAaron Bohy <aab@odoo.com>2019-09-18 11:28:03 +0000
commit2cdd46b566d00aa6c8e6bb9452c3edde120ce2a3 (patch)
tree979a882d7b8eece14b67eb43eceff9bd39d268b7 /addons/web/static/src
parent63289fa06a6ffeb7f5919ba888d7e84d0b16418f (diff)
[FIX] web: list: multi edition: force write same value
Let's assume an editable list view with a many2one field and 2 records: the first one has value 1, the second value 2. The user selects all records and wants to set their many2one to value 1. It edits the first one, sets 1 and validates the confirm dialog. Before this rev., it didn't save anything because the 'reference' record (the one used to edit), didn't actually changed, as we reset the same value. This rev. forces the write the new value on all selected records in that case. Task 2068280
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/list/list_controller.js3
-rw-r--r--addons/web/static/src/js/views/list/list_model.js10
2 files changed, 10 insertions, 3 deletions
diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js
index dc26a750eb4..cf911ef5398 100644
--- a/addons/web/static/src/js/views/list/list_controller.js
+++ b/addons/web/static/src/js/views/list/list_controller.js
@@ -457,6 +457,7 @@ var ListController = BasicController.extend({
*/
_saveMultipleRecords: function (recordId, node, changes) {
var self = this;
+ var fieldName = Object.keys(changes)[0];
var value = Object.values(changes)[0];
var recordIds = _.union([recordId], this.selectedRecords);
var validRecordIds = recordIds.reduce(function (result, nextRecordId) {
@@ -487,7 +488,7 @@ var ListController = BasicController.extend({
}
Dialog.confirm(this, message, {
confirm_callback: () => {
- this.model.saveRecords(recordId, validRecordIds)
+ this.model.saveRecords(recordId, validRecordIds, fieldName)
.then(() => {
this._updateButtons('readonly');
const state = this.model.get(this.handle);
diff --git a/addons/web/static/src/js/views/list/list_model.js b/addons/web/static/src/js/views/list/list_model.js
index 900f3764b0e..65526346c8e 100644
--- a/addons/web/static/src/js/views/list/list_model.js
+++ b/addons/web/static/src/js/views/list/list_model.js
@@ -40,12 +40,18 @@ odoo.define('web.ListModel', function (require) {
* @param {string} referenceRecordId the record datapoint used to
* generate the changes to apply to recordIds
* @param {string[]} recordIds a list of record datapoint ids
+ * @param {string} fieldName the field to write
*/
- saveRecords: function (referenceRecordId, recordIds) {
+ saveRecords: function (referenceRecordId, recordIds, fieldName) {
var self = this;
var referenceRecord = this.localData[referenceRecordId];
var list = this.localData[referenceRecord.parentID];
- var changes = this._generateChanges(referenceRecord, {});
+ // generate all record values to ensure that we'll write something
+ // (e.g. 2 records selected, edit a many2one in the first one, but
+ // reset same value, we still want to save this value on the other
+ // record)
+ var allChanges = this._generateChanges(referenceRecord, {changesOnly: false});
+ var changes = _.pick(allChanges, fieldName);
var records = recordIds.map(function (recordId) {
return self.localData[recordId];
});