From f8274c3a19cd7817d36e87cee1630336acff2107 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 18 Sep 2018 09:09:41 +0100 Subject: [PATCH] [FIX] web_advanced_search: `undefined` in x2m fields Before this patch, when searching with the "equals to" operator in any x2many field, the searched parameter was always `undefined`. The problem was that the underlying field manager implementation was treating those fields as x2many, while the widget used was the `one2many` one. This patch simply mocks the underlying fake record to make think that any relational field is always a `one2many`. This sets all pieces in place and makes the field manager work as expected, and thus you can search as expected too. --- web_advanced_search/static/src/js/web_advanced_search.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web_advanced_search/static/src/js/web_advanced_search.js b/web_advanced_search/static/src/js/web_advanced_search.js index c7d4d7a9..b2e12c75 100644 --- a/web_advanced_search/static/src/js/web_advanced_search.js +++ b/web_advanced_search/static/src/js/web_advanced_search.js @@ -178,6 +178,10 @@ odoo.define("web_advanced_search", function (require) { }; // See https://stackoverflow.com/a/11508530/1468388 params.fields[this.field.name] = _.omit(this.field, "onChange"); + if (this.field.type.endsWith("2many")) { + // X2many fields behave like m2o in the search context + params.fields[this.field.name].type = "many2one"; + } params.fieldsInfo.default[this.field.name] = {}; // Emulate `model.load()`, without RPC-calling `default_get()` this.datapoint_id = this.model._makeDataPoint(params).id;