Skip to content
Snippets Groups Projects
Commit 9500dc0c authored by Saurabh Mishra's avatar Saurabh Mishra
Browse files

[FIX] stock: filter invalid input from domain

When the user tries to find the 'qty_available' of a product but gives
a string value instead of a float value in domain then the user will face error.

Steps to produce:
- Install `stocks`.
- Create a record rule for model `product.template`. In the domain of record
  rule keep [('qty_available', '<', '10')] as a domain,
  you can give any integral value in the domain but that value should be
  enterred as strings (with quotes).
- Inventory > Products > Products

Error: `TypeError: '<' not supported between instances of 'str' and 'float' `

After applying our commit, if the domain is Invalid then the user will face
`UserError`. There is a function named `_search_product_quantity`  which
initially checks if the domain is valid or not :
https://github.com/odoo/odoo/blob/5f1ad0c1e4c1e8ed41337ccd4c12e70c9c760c85/addons/stock/models/product.py#L342-L350


It will filter out all the invalid domain and clear search methods.
So now whenever `_search_qty_available` is called first the validity of domain
and operands of the expression will be checked.

sentry-4399815131

closes odoo/odoo#133155

Signed-off-by: default avatarTiffany Chang (tic) <tic@odoo.com>
parent 4461d90e
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment