summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-08-04 16:09:27 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-08-04 16:09:27 +0700
commita724abaeb7b4f2a2b801b2583776133b5a1adbaa (patch)
treec9622cfb587d330fe49b51ab3cc896413b7951b9
parente415998452e34856e8fb609b677b76f9cfa7b884 (diff)
parent2421dad6c88900949bc2891bc25006ffa838dd78 (diff)
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
-rw-r--r--indoteknik_api/controllers/api_v1/category.py16
-rw-r--r--indoteknik_api/controllers/api_v1/voucher.py7
2 files changed, 7 insertions, 16 deletions
diff --git a/indoteknik_api/controllers/api_v1/category.py b/indoteknik_api/controllers/api_v1/category.py
index b5e01d4e..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])
@@ -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')])
diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py
index f82e1aef..3a2c798e 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 = ''
@@ -43,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']:
@@ -58,6 +59,8 @@ class Voucher(controller.Controller):
apply_status = 'UM' # Unqualified Manufacture
elif subtotal < min_purchase_amount:
apply_status = 'MPA' # Minimum Purchase Amount
+ if has_flashsale_products:
+ apply_status += '-HF' # Has Flashsale
else:
can_apply = True