diff options
| author | Raphael Collet <rco@odoo.com> | 2020-09-18 13:19:51 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-09-18 15:55:04 +0000 |
| commit | 492a37bf49baac862d44bb0b541c04a51e218f1d (patch) | |
| tree | c0f4c6270a3f9853e13b65db1b90eebcac047e75 /odoo/models.py | |
| parent | 5d00592f7d803888d8d5befd5a8cd1b096067860 (diff) | |
[FIX] core: filtered_domain with operators 'like' and 'ilike'
Make the method work when the value to test is `False`.
closes odoo/odoo#58059
X-original-commit: 6fb19219d333dc324603bcb2a937e977eecb037e
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/models.py')
| -rw-r--r-- | odoo/models.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/odoo/models.py b/odoo/models.py index f435e8ef043..b4cde875222 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -5271,20 +5271,24 @@ Fields: elif comparator == 'not in': ok = all(map(lambda x: x not in data, value)) elif comparator == 'not ilike': + data = [(x or "") for x in data] ok = all(map(lambda x: value.lower() not in x.lower(), data)) elif comparator == 'ilike': - data = [x.lower() for x in data] + data = [(x or "").lower() for x in data] ok = bool(fnmatch.filter(data, '*'+(value_esc or '').lower()+'*')) elif comparator == 'not like': + data = [(x or "") for x in data] ok = all(map(lambda x: value not in x, data)) elif comparator == 'like': + data = [(x or "") for x in data] ok = bool(fnmatch.filter(data, value and '*'+value_esc+'*')) elif comparator == '=?': ok = (value in data) or not value elif comparator in ('=like'): + data = [(x or "") for x in data] ok = bool(fnmatch.filter(data, value_esc)) elif comparator in ('=ilike'): - data = [x.lower() for x in data] + data = [(x or "").lower() for x in data] ok = bool(fnmatch.filter(data, value and value_esc.lower())) else: raise ValueError |
