[FIX] account: fix search on account for "=" and "!=" operators
Steps to reproduce:
- Create 2 accounts:
1)
* Code: 1000
* Account Name: Test
2)
* Code 1000A
* Account Name: TestA
- Create a journal item for each account
- Go to Accounting / Accounting / Journal Items (list view)
- Add custom filter: ("Account", "is equal to", "1000 Test")
Journal items from both the created accounts are retrieved.
As a strict equal is requested, it shouldn't find the journal item
linked to account "1000A TestA".
Cause:
When searching on an account, the first part of the search is used
to find a code that begins with that part (ilike operation), regardless
of the actual operator (i.e. "=" in this case).
It has been done that way because we suppose that most of the times
customer is starting his search with the beginning of the code of the
account he is searching, which is not incorrect.
But the case of the "=" operator has not been handled.
opw-3179681
closes odoo/odoo#114927
X-original-commit: dfd9bee8c07b927a97823eb8ede7dc2b2a4c435a
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: Anh Thao PHAM <pta@odoo.com>
This commit is contained in:
@@ -566,7 +566,10 @@ class AccountAccount(models.Model):
|
||||
self.env.company.id, self._context.get('partner_id'), self._context.get('move_type'))
|
||||
domain = domain or []
|
||||
if name:
|
||||
name_domain = ['|', ('code', '=ilike', name.split(' ')[0] + '%'), ('name', operator, name)]
|
||||
if operator in ('=', '!='):
|
||||
name_domain = ['|', ('code', '=', name.split(' ')[0]), ('name', operator, name)]
|
||||
else:
|
||||
name_domain = ['|', ('code', '=ilike', name.split(' ')[0] + '%'), ('name', operator, name)]
|
||||
if operator in expression.NEGATIVE_TERM_OPERATORS:
|
||||
name_domain = ['&', '!'] + name_domain[1:]
|
||||
domain = expression.AND([name_domain, domain])
|
||||
|
||||
Reference in New Issue
Block a user