[FIX] *: Fix bad usage of 'like'/'ilike' operator
The 'like'/'ilike' operators automatically add the wildcard character (`%`) at the beginning and at the end of the value. This commit fixes the incorrect usage. closes odoo/odoo#136007 Related: odoo/enterprise#47886 Signed-off-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
@@ -601,7 +601,7 @@ class AccountJournal(models.Model):
|
||||
journal_code_base = prefix_map.get(journal_type)
|
||||
existing_codes = set(self.env['account.journal'].with_context(active_test=False).search([
|
||||
*self.env['account.journal']._check_company_domain(company),
|
||||
('code', 'like', journal_code_base + '%'),
|
||||
('code', '=like', journal_code_base + '%'),
|
||||
]).mapped('code') + (cache or []))
|
||||
|
||||
for num in range(1, 100):
|
||||
|
||||
@@ -137,7 +137,7 @@ class AccountReport(models.Model):
|
||||
# as their sections
|
||||
if report.root_report_id:
|
||||
report[field_name] = report.root_report_id[field_name]
|
||||
elif len(report.section_main_report_ids) == 1 and not self.env['ir.actions.client'].search_count([('context', 'ilike', f"%'report_id': {report.id}"), ('tag', '=', 'account_report')]):
|
||||
elif len(report.section_main_report_ids) == 1 and not self.env['ir.actions.client'].search_count([('context', 'ilike', f"'report_id': {report.id}"), ('tag', '=', 'account_report')]):
|
||||
report[field_name] = report.section_main_report_ids[field_name]
|
||||
else:
|
||||
report[field_name] = default_value
|
||||
|
||||
@@ -18,7 +18,7 @@ def test_all_l10n(env):
|
||||
|
||||
# Install the requiriments
|
||||
l10n_mods = env['ir.module.module'].search([
|
||||
('name', 'like', 'l10n%'),
|
||||
('name', '=like', 'l10n%'),
|
||||
('state', '=', 'uninstalled'),
|
||||
])
|
||||
l10n_mods.button_immediate_install()
|
||||
|
||||
@@ -286,7 +286,7 @@ class TestChartTemplate(TransactionCase):
|
||||
self.env['account.chart.template'].try_loading('test', company=company_2, install_demo=False)
|
||||
|
||||
taxes_1_companies = self.env['account.tax'].search([
|
||||
('name', 'like', '%Tax 1'),
|
||||
('name', '=like', '%Tax 1'),
|
||||
('company_id', 'in', [self.company_1.id, company_2.id]),
|
||||
])
|
||||
# we should have 4 records: 2 companies * (1 original tax + 1 recreated tax)
|
||||
|
||||
@@ -71,7 +71,7 @@ class TaxReportTest(AccountTestInvoicingCommon):
|
||||
def _get_tax_tags(self, country, tag_name=None, active_test=True):
|
||||
domain = [('country_id', '=', country.id), ('applicability', '=', 'taxes')]
|
||||
if tag_name:
|
||||
domain.append(('name', 'like', '_' + tag_name))
|
||||
domain.append(('name', '=like', '_' + tag_name))
|
||||
return self.env['account.account.tag'].with_context(active_test=active_test).search(domain)
|
||||
|
||||
def test_create_shared_tags(self):
|
||||
|
||||
@@ -127,7 +127,7 @@ class AccountMove(models.Model):
|
||||
"""
|
||||
it_tax_report_vj_lines = self.env['account.report.line'].search([
|
||||
('report_id.country_id.code', '=', 'IT'),
|
||||
('code', 'like', 'VJ%'),
|
||||
('code', '=like', 'VJ%'),
|
||||
])
|
||||
vj_lines_tags = it_tax_report_vj_lines.expression_ids._get_matching_tags()
|
||||
for move in self:
|
||||
|
||||
@@ -156,7 +156,7 @@ class StockWarehouse(models.Model):
|
||||
|
||||
def _get_sequence_values(self, name=False, code=False):
|
||||
values = super(StockWarehouse, self)._get_sequence_values(name=name, code=code)
|
||||
count = self.env['ir.sequence'].search_count([('prefix', 'like', self.code + '/SBC%/%')])
|
||||
count = self.env['ir.sequence'].search_count([('prefix', '=like', self.code + '/SBC%/%')])
|
||||
values.update({
|
||||
'subcontracting_type_id': {
|
||||
'name': self.name + ' ' + _('Sequence subcontracting'),
|
||||
|
||||
@@ -372,7 +372,7 @@ class PaymentTransaction(models.Model):
|
||||
# query wouldn't help either as the selector is arbitrary and doing that would be an
|
||||
# open-door to SQL injections.
|
||||
same_prefix_references = self.sudo().search(
|
||||
[('reference', 'like', f'{prefix}{separator}%')]
|
||||
[('reference', '=like', f'{prefix}{separator}%')]
|
||||
).with_context(prefetch_fields=False).mapped('reference')
|
||||
|
||||
# A final regex search is necessary to figure out the next sequence number. The previous
|
||||
|
||||
@@ -11,7 +11,7 @@ from . import populate
|
||||
# TODO: Apply proper fix & remove in master
|
||||
def pre_init_hook(env):
|
||||
env['ir.model.data'].search([
|
||||
('model', 'like', '%stock%'),
|
||||
('model', 'like', 'stock'),
|
||||
('module', '=', 'stock')
|
||||
]).unlink()
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ class StockPicking(models.Model):
|
||||
def _compute_return_label(self):
|
||||
for picking in self:
|
||||
if picking.carrier_id:
|
||||
picking.return_label_ids = self.env['ir.attachment'].search([('res_model', '=', 'stock.picking'), ('res_id', '=', picking.id), ('name', 'like', '%s%%' % picking.carrier_id.get_return_label_prefix())])
|
||||
picking.return_label_ids = self.env['ir.attachment'].search([('res_model', '=', 'stock.picking'), ('res_id', '=', picking.id), ('name', '=like', '%s%%' % picking.carrier_id.get_return_label_prefix())])
|
||||
else:
|
||||
picking.return_label_ids = False
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class Assets(models.AbstractModel):
|
||||
IrAttachment.search([
|
||||
'|', ('id', '=', delete_attachment_id),
|
||||
('original_id', '=', delete_attachment_id),
|
||||
('name', 'like', '%google-font%')
|
||||
('name', 'like', 'google-font'),
|
||||
]).unlink()
|
||||
|
||||
google_local_fonts = values.get('google-local-fonts')
|
||||
|
||||
@@ -127,15 +127,15 @@ class TestGroups(TransactionCase):
|
||||
def test_res_groups_fullname_search(self):
|
||||
all_groups = self.env['res.groups'].search([])
|
||||
|
||||
groups = all_groups.search([('full_name', 'like', '%Sale%')])
|
||||
groups = all_groups.search([('full_name', 'like', 'Sale')])
|
||||
self.assertItemsEqual(groups.ids, [g.id for g in all_groups if 'Sale' in g.full_name],
|
||||
"did not match search for 'Sale'")
|
||||
|
||||
groups = all_groups.search([('full_name', 'like', '%Technical%')])
|
||||
groups = all_groups.search([('full_name', 'like', 'Technical')])
|
||||
self.assertItemsEqual(groups.ids, [g.id for g in all_groups if 'Technical' in g.full_name],
|
||||
"did not match search for 'Technical'")
|
||||
|
||||
groups = all_groups.search([('full_name', 'like', '%Sales /%')])
|
||||
groups = all_groups.search([('full_name', 'like', 'Sales /')])
|
||||
self.assertItemsEqual(groups.ids, [g.id for g in all_groups if 'Sales /' in g.full_name],
|
||||
"did not match search for 'Sales /'")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user