summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/product.py
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2022-11-17 11:15:09 +0700
committerIT Fixcomart <it@fixcomart.co.id>2022-11-17 11:15:09 +0700
commit7f08a09863e6bd8771e1de943228abdaf019a698 (patch)
tree00f69ced1fe6897d83ec51ddcbc5842ba09beb06 /indoteknik_api/controllers/api_v1/product.py
parent0195aeb8b16a46792eabc3491e186ee869b814ee (diff)
fallback pricelist and product solr by name
Diffstat (limited to 'indoteknik_api/controllers/api_v1/product.py')
-rw-r--r--indoteknik_api/controllers/api_v1/product.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py
index 667347d4..09ea459d 100644
--- a/indoteknik_api/controllers/api_v1/product.py
+++ b/indoteknik_api/controllers/api_v1/product.py
@@ -79,7 +79,7 @@ class Product(controller.Controller):
if not self.authenticate():
return self.response(code=401, description='Unauthorized')
- query = [('sale_ok', '=', True)]
+ name = kw.get('name')
solr_flag = kw.get('flag')
limit = int(kw.get('limit', 0))
offset = int(kw.get('offset', 0))
@@ -87,16 +87,17 @@ class Product(controller.Controller):
if not solr_flag:
return self.response(code=400, description='flag is required')
- if solr_flag:
- query.append(('solr_flag', '=', int(solr_flag)))
-
- product_variants = request.env['product.product'].search(query)
- product_variant_ids = [x.id for x in product_variants]
query = [
- '|',
- ('solr_flag', '=', int(solr_flag)),
- ('product_variant_ids', 'in', product_variant_ids)
+ ('sale_ok', '=', True),
+ ('solr_flag', '=', int(solr_flag))
]
+ if name:
+ name = '%' + name.replace(' ', '%') + '%'
+ query += [
+ '|',
+ ('default_code', 'ilike', name),
+ ('name', 'ilike', name),
+ ]
product_templates = request.env['product.template'].search(query, limit=limit, offset=offset)
data = {
'product_total': request.env['product.template'].search_count(query),