Browse Source

[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.
pull/1197/head
Jairo Llopis 6 years ago
committed by Pedro M. Baeza
parent
commit
f8274c3a19
  1. 4
      web_advanced_search/static/src/js/web_advanced_search.js

4
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;

Loading…
Cancel
Save