Skip to content

Commit 23814f1

Browse files
author
Ethan Vincent
committed
[REV] base: no transformation search tokens res_country name_search
revert of commit: ea6d105 this commit broke some legit existing filters (multi-word country name, etc.) more details here: odoo#218960 closes odoo#219033 Signed-off-by: Vincent Ethan <etvi@odoo.com>
1 parent 385627f commit 23814f1

2 files changed

Lines changed: 8 additions & 49 deletions

File tree

odoo/addons/base/models/res_country.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ def _name_search(self, name, domain=None, operator='ilike', limit=None, order=No
8989
ids = []
9090
if len(name) == 2:
9191
ids = list(self._search([('code', 'ilike', name)] + domain, limit=limit, order=order))
92-
elif operator in ('=', '!=', 'in', 'not in'):
93-
if isinstance(name, str):
94-
name = name.capitalize()
95-
else: # iterable
96-
name = [n.capitalize() if n else n for n in name]
9792

9893
search_domain = [('name', operator, name)]
9994
if ids:

odoo/addons/base/tests/test_res_country.py

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,21 @@
11
from odoo.tests import TransactionCase, tagged
22

33

4-
class TestResCountryCommon(TransactionCase):
5-
@classmethod
6-
def setUpClass(cls):
7-
super().setUpClass()
8-
cls.glorious_arstotzka = cls.env['res.country'].create({
4+
@tagged('-at_install', 'post_install')
5+
class TestResCountryState(TransactionCase):
6+
def test_find_by_name(self):
7+
"""It should be possible to find a state by its display name
8+
"""
9+
glorious_arstotzka = self.env['res.country'].create({
910
'name': 'Arstotzka',
1011
'code': 'AA',
1112
})
12-
cls.altan = cls.env['res.country.state'].create({
13-
'country_id': cls.glorious_arstotzka.id,
13+
altan = self.env['res.country.state'].create({
14+
'country_id': glorious_arstotzka.id,
1415
'code': 'AL',
1516
'name': 'Altan',
1617
})
1718

18-
19-
@tagged('-at_install', 'post_install')
20-
class TestResCountry(TestResCountryCommon):
21-
def test_name_search(self):
22-
glorious_arstotzka_tuple = (self.glorious_arstotzka.id, self.glorious_arstotzka.display_name)
23-
for (name, op) in [
24-
('ARSTOTZKA', '='),
25-
('arstotzka', '='),
26-
('ARSTOTZKA', '!='),
27-
('arstotzka', '!='),
28-
(['ARSTOTZKA'], 'in'),
29-
(['arstotzka'], 'in'),
30-
(['ARSTOTZKA'], 'not in'),
31-
(['arstotzka'], 'not in'),
32-
]:
33-
with self.subTest((name, op)):
34-
assertFunc = self.assertNotIn if op in ('!=', 'not in') else self.assertEqual
35-
assertFunc(
36-
[glorious_arstotzka_tuple],
37-
self.env['res.country'].name_search(name, operator=op),
38-
f"Failed on operator: '{op}'"
39-
)
40-
41-
def test_name_search_code(self):
42-
glorious_arstotzka_tuple = (self.glorious_arstotzka.id, self.glorious_arstotzka.display_name)
43-
res = self.env['res.country'].name_search('aA', operator='=')
44-
self.assertEqual(res, [glorious_arstotzka_tuple])
45-
46-
47-
@tagged('-at_install', 'post_install')
48-
class TestResCountryState(TestResCountryCommon):
49-
def test_find_by_name(self):
50-
"""It should be possible to find a state by its display name
51-
"""
52-
glorious_arstotzka = self.glorious_arstotzka
53-
altan = self.altan
54-
5519
for name in [
5620
altan.name,
5721
altan.display_name,

0 commit comments

Comments
 (0)