mirror of https://github.com/OCA/web.git
[13.0][IMP] web_m2x_options
This is a forward port of * https://github.com/OCA/web/pull/651pull/1761/head
parent
21eee65a4e
commit
ee1e795a00
|
@ -235,57 +235,59 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
|
||||||
self.ir_options["web_m2x_options.search_more"]
|
self.ir_options["web_m2x_options.search_more"]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (values.length > self.limit) {
|
if (
|
||||||
|
(values.length > self.limit &&
|
||||||
|
(can_search_more || search_more_undef)) ||
|
||||||
|
search_more
|
||||||
|
) {
|
||||||
values = values.slice(0, self.limit);
|
values = values.slice(0, self.limit);
|
||||||
if (can_search_more || search_more_undef || search_more) {
|
values.push({
|
||||||
values.push({
|
label: _t("Search More..."),
|
||||||
label: _t("Search More..."),
|
action: function() {
|
||||||
action: function() {
|
var prom = [];
|
||||||
var prom = [];
|
if (search_val !== "") {
|
||||||
if (search_val !== "") {
|
prom = self._rpc({
|
||||||
prom = self._rpc({
|
model: self.field.relation,
|
||||||
model: self.field.relation,
|
method: "name_search",
|
||||||
method: "name_search",
|
kwargs: {
|
||||||
kwargs: {
|
name: search_val,
|
||||||
name: search_val,
|
args: domain,
|
||||||
args: domain,
|
operator: "ilike",
|
||||||
operator: "ilike",
|
limit: self.SEARCH_MORE_LIMIT,
|
||||||
limit: self.SEARCH_MORE_LIMIT,
|
context: context,
|
||||||
context: context,
|
},
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Promise.resolve(prom).then(function(results) {
|
|
||||||
var dynamicFilters = [];
|
|
||||||
if (results) {
|
|
||||||
var ids = _.map(results, function(x) {
|
|
||||||
return x[0];
|
|
||||||
});
|
|
||||||
if (search_val) {
|
|
||||||
dynamicFilters = [
|
|
||||||
{
|
|
||||||
description: _.str.sprintf(
|
|
||||||
_t("Quick search: %s"),
|
|
||||||
search_val
|
|
||||||
),
|
|
||||||
domain: [["id", "in", ids]],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
dynamicFilters = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self._searchCreatePopup(
|
|
||||||
"search",
|
|
||||||
false,
|
|
||||||
{},
|
|
||||||
dynamicFilters
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
classname: "o_m2o_dropdown_option",
|
Promise.resolve(prom).then(function(results) {
|
||||||
});
|
var dynamicFilters = [];
|
||||||
}
|
if (results) {
|
||||||
|
var ids = _.map(results, function(x) {
|
||||||
|
return x[0];
|
||||||
|
});
|
||||||
|
if (search_val) {
|
||||||
|
dynamicFilters = [
|
||||||
|
{
|
||||||
|
description: _.str.sprintf(
|
||||||
|
_t("Quick search: %s"),
|
||||||
|
search_val
|
||||||
|
),
|
||||||
|
domain: [["id", "in", ids]],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
dynamicFilters = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self._searchCreatePopup(
|
||||||
|
"search",
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
dynamicFilters
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
classname: "o_m2o_dropdown_option",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var create_enabled = self.can_create && !self.nodeOptions.no_create;
|
var create_enabled = self.can_create && !self.nodeOptions.no_create;
|
||||||
|
|
Loading…
Reference in New Issue