Merge PR #1554 into 12.0

Signed-off-by Yajo
This commit is contained in:
OCA-git-bot
2020-03-23 10:12:23 +00:00
5 changed files with 24 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
# Copyright 2015 Therp BV <http://therp.nl>
# Copyright 2017 Tecnativa - Vicent Cubells
# Copyright 2018 Tecnativa - Jairo Llopis
# Copyright 2020 Brainbean Apps (https://brainbeanapps.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{

View File

@@ -5,3 +5,4 @@
* Jose Mª Bernet <josemaria.bernet@guadaltech.es>
* Simone Orsi <simone.orsi@camptocamp.com>
* Dennis Sluijk <d.sluijk@onestein.nl>
* Alexey Pelykh <alexey.pelykh@brainbeanapps.com>

View File

@@ -8,3 +8,7 @@ Improvements to the search view in this addon:
* Use widgets ``one2many_tags`` when searching ``one2many`` fields
* Use widgets ``many2many_tags`` when searching ``many2many`` fields
* Allow to edit current full search using the advanced domain editor
Improvements to the `is child of`/`is parent of` operators:
* Show the operators only for models with `_parent_store = True`

View File

@@ -2,7 +2,8 @@ To use this module, you need to:
* Open *Filters* in a search view
* Select any relational field
* Select operator `is equal to` or `is not equal to`
* Select one of operators: `is equal to`, `is not equal to`, `is child of`,
or `is parent of`
* The text field changes to a relational selection field where you
can search for the record in question
* Click *Apply*

View File

@@ -1,5 +1,6 @@
/* Copyright 2015 Therp BV <http://therp.nl>
* Copyright 2017-2018 Jairo Llopis <jairo.llopis@tecnativa.com>
* Copyright 2020 Brainbean Apps (https://brainbeanapps.com)
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
odoo.define("web_advanced_search", function (require) {
@@ -16,6 +17,8 @@ odoo.define("web_advanced_search", function (require) {
var Widget = require("web.Widget");
var Char = core.search_filters_registry.get("char");
var _lt = core._lt;
SearchView.include({
custom_events: _.extend({}, SearchView.prototype.custom_events, {
"get_dataset": "_on_get_dataset",
@@ -153,14 +156,23 @@ odoo.define("web_advanced_search", function (require) {
// To make widgets work, we need a model and an empty record
FieldManagerMixin.init.call(this);
this.trigger_up("get_dataset");
// Make equal and not equal appear 1st and 2nd
// Unfortunately, it's impossible to check if model supports these
this.operators = this.operators.concat([
{value: "child_of", text: _lt("is child of")},
{value: "parent_of", text: _lt("is parent of")}
])
// Prioritize equal, not equal, child_of, parent_of
this.operators = _.sortBy(
this.operators,
function (op) {
switch (op.value) {
case "=":
return -2;
return -4;
case "!=":
return -3;
case "child_of":
return -2;
case "parent_of":
return -1;
default:
return 0;
@@ -242,6 +254,8 @@ odoo.define("web_advanced_search", function (require) {
switch ($operator.val()) {
case "=":
case "!=":
case "child_of":
case "parent_of":
this._field_widget_name = "many2one";
break;
default: