Skip to content

Commit

Permalink
[FIX] stock: search on location with negative operator
Browse files Browse the repository at this point in the history
- Go to Inventory > Reporting > Inventory Report
- Filter the location with a negative operator, e.g. 'Location doesn't
  contain "shelf"'

Locations containing 'shelf' are displayed anyway.

We are adding this condition: `'|', ('barcode', operator, name)`. Since
barcode is empty (or at least doesn't contain 'shelf'), the condition is
met and all records are retrieved.

In case of a negative operator, both `barcode` and `complete_name`
must not match.

opw-2281191

closes odoo#53707

X-original-commit: 8fedbcd
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information
nim-odoo committed Jun 26, 2020
1 parent bbdc3c4 commit d5dee48
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addons/stock/models/stock_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_ui
args = args or []
if operator == 'ilike' and not (name or '').strip():
domain = []
elif operator in expression.NEGATIVE_TERM_OPERATORS:
domain = [('barcode', operator, name), ('complete_name', operator, name)]
else:
domain = ['|', ('barcode', operator, name), ('complete_name', operator, name)]
location_ids = self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid)
Expand Down

0 comments on commit d5dee48

Please sign in to comment.