diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-07-31 16:31:42 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-07-31 16:31:42 +0700 |
| commit | f785e7605f4d0151a0f48e3d871b996c40e51351 (patch) | |
| tree | 937bc48e019bb7963126cfaa52f31c8a343e52bd /indoteknik_api/models | |
| parent | 1563299905b3e0cf97129739c0ee0a6269ce4bc8 (diff) | |
Add flash sale tag on model, view, api response
Diffstat (limited to 'indoteknik_api/models')
| -rw-r--r-- | indoteknik_api/models/product_template.py | 7 |
1 files changed, 5 insertions, 2 deletions
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, |
