[IMP] base: allow non-administrators to search res.groups by names

before this commit:
users without read permission of ir.module.category cannot search
res.groups by names. An access error will be raised.

after this commit:
all users with read permission of res.groups can search res.groups
by names

closes odoo/odoo#97877

Signed-off-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
Chong Wang (cwg)
2022-08-10 19:15:53 +02:00
parent ee9b28b546
commit 51c7734ef3
+4 -6
View File
@@ -162,11 +162,7 @@ class Groups(models.Model):
def _search_full_name(self, operator, operand):
lst = True
if isinstance(operand, bool):
domains = [[('name', operator, operand)], [('category_id.name', operator, operand)]]
if operator in expression.NEGATIVE_TERM_OPERATORS == (not operand):
return expression.AND(domains)
else:
return expression.OR(domains)
return [[('name', operator, operand)]]
if isinstance(operand, str):
lst = False
operand = [operand]
@@ -176,7 +172,9 @@ class Groups(models.Model):
group_name = values.pop().strip()
category_name = values and '/'.join(values).strip() or group_name
group_domain = [('name', operator, lst and [group_name] or group_name)]
category_domain = [('category_id.name', operator, lst and [category_name] or category_name)]
category_ids = self.env['ir.module.category'].sudo()._search(
[('name', operator, [category_name] if lst else category_name)])
category_domain = [('category_id', 'in', category_ids)]
if operator in expression.NEGATIVE_TERM_OPERATORS and not values:
category_domain = expression.OR([category_domain, [('category_id', '=', False)]])
if (operator in expression.NEGATIVE_TERM_OPERATORS) == (not values):