mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
@@ -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).
|
||||
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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`
|
||||
|
||||
@@ -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*
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user