From 00e7ef0fbbaa72c99e66faa48ff8b107d9ca7c6a Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 15 Jul 2024 10:34:51 +0700 Subject: cr flashsale api --- indoteknik_api/models/product_pricelist.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indoteknik_api/models') diff --git a/indoteknik_api/models/product_pricelist.py b/indoteknik_api/models/product_pricelist.py index 0d4247c8..6e88517c 100644 --- a/indoteknik_api/models/product_pricelist.py +++ b/indoteknik_api/models/product_pricelist.py @@ -95,6 +95,20 @@ class ProductPricelist(models.Model): ], limit=1, order='start_date asc') return pricelist + def get_is_show_program_flash_sale(self): + """ + Check whether have active flash sale in range of date + @return: returns pricelist: object + """ + current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + pricelist = self.search([ + ('is_flash_sale', '=', True), + ('is_show_program', '=', True), + ('start_date', '<=', current_time), + ('end_date', '>=', current_time) + ], order='start_date asc') + return pricelist + def is_flash_sale_product(self, product_id: int): """ Check whether product is flash sale. -- cgit v1.2.3