Files
web/web_advanced_search_wildcard/static/src/js/search.js
2019-07-10 10:51:02 +02:00

30 lines
1.2 KiB
JavaScript

odoo.define('web_advanced_search_wildcard', function (require) {
"use strict";
var core = require('web.core');
var Char = core.search_filters_registry.get('char')
var _lt = core._lt;
Char.prototype.operators.push(
{value: "startswith", text: _lt("starts with")},
{value: "not_startswith", text: _lt("doesn't start with")},
{value: "endswith", text: _lt("ends with")},
{value: "not_endswith", text: _lt("doesn't end with")},
{value: '=ilike', text: _lt("matches")}
);
Char.include({
get_domain: function (field, operator) {
switch (operator.value) {
case '∃': return [[field.name, '!=', false]];
case '∄': return [[field.name, '=', false]];
case 'startswith': return [[field.name, '=ilike', this.get_value() + '%']];
case 'not_startswith': return ['!', [field.name, '=ilike', this.get_value() + '%']];
case 'endswith': return [[field.name, '=ilike', '%' + this.get_value()]];
case 'not_endswith': return ['!', [field.name, '=ilike', '%' + this.get_value()]];
default: return [[field.name, operator.value, this.get_value()]];
}
},
});
});