diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-11-17 17:20:23 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-11-17 17:20:23 +0700 |
| commit | 96af7230bdd79234fadeca8110b65dafa5b70a53 (patch) | |
| tree | f3f37c555fe939852db2659f52e344e48acc1202 /indoteknik_api/controllers/api_v1 | |
| parent | fa27a62a2ecc046020e57849838b633d78a99c36 (diff) | |
| parent | f168734f000ea34fc3a15bdf4b6af9f4fe797d06 (diff) | |
Merge branch 'master' of git@bitbucket.org:altafixco/indoteknik-addons.git
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/login.py | 2 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product.py | 19 |
2 files changed, 11 insertions, 10 deletions
diff --git a/indoteknik_api/controllers/api_v1/login.py b/indoteknik_api/controllers/api_v1/login.py index cc440d26..5c6251ae 100644 --- a/indoteknik_api/controllers/api_v1/login.py +++ b/indoteknik_api/controllers/api_v1/login.py @@ -15,7 +15,7 @@ class Cart(controller.Controller): email = kw.get('email') password = kw.get('password') if not email or not password: - return self.response(code=400, description='username and password is required') + return self.response(code=400, description='email and password is required') try: uid = request.session.authenticate(config.get('db_name'), email, password) 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), |
