From f785e7605f4d0151a0f48e3d871b996c40e51351 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 31 Jul 2023 16:31:42 +0700 Subject: Add flash sale tag on model, view, api response --- indoteknik_api/models/product_template.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indoteknik_api/models') diff --git a/indoteknik_api/models/product_template.py b/indoteknik_api/models/product_template.py index b01e957b..fb77769f 100644 --- a/indoteknik_api/models/product_template.py +++ b/indoteknik_api/models/product_template.py @@ -70,9 +70,12 @@ class ProductTemplate(models.Model): for variant in variants: if variant["price"]["price_discount"] < lowest_price["price_discount"]: lowest_price = variant['price'] - + template_pricelist = product_template._get_active_flash_sale() data_with_detail = { - 'flash_sale_remaining_time': product_template._get_flash_sale_remaining_time(), + 'flash_sale': { + 'remaining_time': template_pricelist._remaining_time_in_second() if template_pricelist else 0, + 'tag': template_pricelist.flashsale_tag if template_pricelist else None + }, 'lowest_price': lowest_price, 'image': self.env['ir.attachment'].api_image('product.template', 'image_512', product_template.id), 'display_name': product_template.display_name, -- cgit v1.2.3