From 7840645f90d9ec8bebaeb7c7239b7df9a7e04f53 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 4 Aug 2023 11:33:16 +0700 Subject: Add has flash sale condition on voucher API --- indoteknik_api/controllers/api_v1/voucher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py index f82e1aef..aef46375 100644 --- a/indoteknik_api/controllers/api_v1/voucher.py +++ b/indoteknik_api/controllers/api_v1/voucher.py @@ -57,7 +57,10 @@ class Voucher(controller.Controller): if not has_match_manufacture: apply_status = 'UM' # Unqualified Manufacture elif subtotal < min_purchase_amount: - apply_status = 'MPA' # Minimum Purchase Amount + if has_flashsale_products: + apply_status = 'HFMPA' # Has Flashsale Minimum Purchase Amount + else: + apply_status = 'MPA' # Minimum Purchase Amount else: can_apply = True -- cgit v1.2.3 From cda676bfacedf7489e091887e104a551536ffe77 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 4 Aug 2023 13:10:26 +0700 Subject: Add has flash sale condition on voucher API --- indoteknik_api/controllers/api_v1/voucher.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py index aef46375..4e099fc0 100644 --- a/indoteknik_api/controllers/api_v1/voucher.py +++ b/indoteknik_api/controllers/api_v1/voucher.py @@ -57,10 +57,9 @@ class Voucher(controller.Controller): if not has_match_manufacture: apply_status = 'UM' # Unqualified Manufacture elif subtotal < min_purchase_amount: + apply_status = 'MPA' # Minimum Purchase Amount if has_flashsale_products: - apply_status = 'HFMPA' # Has Flashsale Minimum Purchase Amount - else: - apply_status = 'MPA' # Minimum Purchase Amount + apply_status += '-HF' # Has Flashsale else: can_apply = True -- cgit v1.2.3 From b13c2905bbc409ced20b05e693779aba1c8f7768 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 4 Aug 2023 13:22:08 +0700 Subject: Update get voucher with source --- indoteknik_api/controllers/api_v1/voucher.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py index 4e099fc0..0ecdd20d 100644 --- a/indoteknik_api/controllers/api_v1/voucher.py +++ b/indoteknik_api/controllers/api_v1/voucher.py @@ -12,6 +12,7 @@ class Voucher(controller.Controller): cart = request.env['website.user.cart'] code = kw.get('code') user_id = kw.get('user_id') + source = kw.get('source') visibility = ['public'] parameter = [] @@ -25,7 +26,7 @@ class Voucher(controller.Controller): parameter += [('visibility', 'in', visibility)] vouchers = request.env['voucher'].get_active_voucher(parameter) vouchers = vouchers.res_format() - checkout = cart.get_user_checkout(user_id) + checkout = cart.get_user_checkout(user_id, source=source) for voucher in vouchers: apply_status = '' -- cgit v1.2.3 From 99782534a66b3db276bb2c973e75b976a22ba864 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 4 Aug 2023 13:52:27 +0700 Subject: Update category homepage show product from product_ids --- indoteknik_api/controllers/api_v1/category.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/category.py b/indoteknik_api/controllers/api_v1/category.py index b5e01d4e..22b5cb44 100644 --- a/indoteknik_api/controllers/api_v1/category.py +++ b/indoteknik_api/controllers/api_v1/category.py @@ -69,17 +69,7 @@ class Category(controller.Controller): categories = request.env['website.categories.homepage'].search(query, order='sequence') data = [] for category in categories: - query_product = [ - ('active', '=', True), - ('type', '=', 'product'), - ('product_rating', '>', 0), - ('public_categ_ids', 'child_of', [category.category_id.id]) - ] - products = request.env['product.template'].search(query_product, order='product_rating desc', limit=12) - # product_brands = [] - brands = request.env['x_manufactures'].search([ - ('product_tmpl_ids.public_categ_ids', 'child_of', [category.category_id.id]) - ], limit=8) + products = category.product_ids data.append({ 'id': category.id, @@ -88,8 +78,6 @@ class Category(controller.Controller): 'name': category.category_id.name, 'image': request.env['ir.attachment'].api_image('website.categories.homepage', 'image', category.id), 'url': category.url, - # 'brands': [y.x_name for y in brands], - 'brands': [request.env['x_manufactures'].api_single_response(y) for y in brands], 'products': [request.env['product.template'].api_single_response(x) for x in products] }) return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')]) -- cgit v1.2.3 From 339c3f00bc33fae434c8394885b71471b281d7c7 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 4 Aug 2023 14:09:46 +0700 Subject: Fix get voucher API --- indoteknik_api/controllers/api_v1/voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py index 0ecdd20d..3a2c798e 100644 --- a/indoteknik_api/controllers/api_v1/voucher.py +++ b/indoteknik_api/controllers/api_v1/voucher.py @@ -44,7 +44,7 @@ class Voucher(controller.Controller): quantity = product['quantity'] manufacture_id = product['manufacture']['id'] or False - if len(manufacture_ids) == 0 or (not product['has_flashsale'] and manufacture_id in manufacture_ids): + if len(manufacture_ids) == 0 or manufacture_id in manufacture_ids: has_match_manufacture = True if product['has_flashsale']: -- cgit v1.2.3 From ae7bed568731a6fda0156f2b170ba1bad84624be Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 4 Aug 2023 14:17:28 +0700 Subject: Fix sequence product category homepage API --- indoteknik_api/controllers/api_v1/category.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/category.py b/indoteknik_api/controllers/api_v1/category.py index 22b5cb44..efbf52f2 100644 --- a/indoteknik_api/controllers/api_v1/category.py +++ b/indoteknik_api/controllers/api_v1/category.py @@ -54,7 +54,7 @@ class Category(controller.Controller): @controller.Controller.must_authorized() def get_categories_homepage_count(self): query = [('status', '=', 'tayang')] - categories = request.env['website.categories.homepage'].search_read(query, ['id']) + categories = request.env['website.categories.homepage'].search_read(query, ['id'], order="sequence") return self.response([x['id'] for x in categories]) -- cgit v1.2.3