summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 9efd76985cc..0ad11dba91a 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -2762,9 +2762,20 @@ var FieldMany2ManyCheckBoxes = AbstractField.extend({
* @private
*/
_onChange: function () {
+ // Get the list of selected ids
var ids = _.map(this.$('input:checked'), function (input) {
return $(input).data("record-id");
});
+ // The number of displayed checkboxes is limited to 100 (name_search
+ // limit, server-side), to prevent extreme cases where thousands of
+ // records are fetched/displayed. If not all values are displayed, it may
+ // happen that some values that are in the relation aren't available in the
+ // widget. In this case, when the user (un)selects a value, we don't
+ // want to remove those non displayed values from the relation. For that
+ // reason, we manually add those values to the list of ids.
+ const displayedIds = this.m2mValues.map(v => v[0]);
+ const idsInRelation = this.value.res_ids;
+ ids = ids.concat(idsInRelation.filter(a => !displayedIds.includes(a)));
this._setValue({
operation: 'REPLACE_WITH',
ids: ids,