From 1c18f6c7438537a60f181d089df06a0b4ba915f9 Mon Sep 17 00:00:00 2001 From: IT Fixcomart Date: Wed, 5 Oct 2022 16:33:32 +0700 Subject: Float duration flash sale and response 404 data not found --- indoteknik_api/controllers/product_controller.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indoteknik_api/controllers/product_controller.py') diff --git a/indoteknik_api/controllers/product_controller.py b/indoteknik_api/controllers/product_controller.py index a127b790..0f29971c 100644 --- a/indoteknik_api/controllers/product_controller.py +++ b/indoteknik_api/controllers/product_controller.py @@ -86,7 +86,7 @@ class ProductController(controller.Controller): if active_flash_sale: flash_sale = { 'banner': base_url + 'api/image/product.pricelist/banner/' + str(active_flash_sale.id) if active_flash_sale.banner else '', - 'duration': (active_flash_sale.end_date - datetime.now()).total_seconds(), + 'duration': round((active_flash_sale.end_date - datetime.now()).total_seconds()), 'products': [] } product_pricelist_item = request.env['product.pricelist.item'].search([('pricelist_id', '=', active_flash_sale.id)]) @@ -104,6 +104,8 @@ class ProductController(controller.Controller): 'promotion': self.get_promotion_by_product(product), }) data.update({'flash_sale': flash_sale}) + else: + return self.response(code=404, description='Data not found') return self.response(data) def get_stock_by_product(self, product_template: object): -- cgit v1.2.3