summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/product_pricelist.py7
-rwxr-xr-xindoteknik_custom/models/product_template.py8
2 files changed, 8 insertions, 7 deletions
diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py
index 49927d6b..95e63cf0 100644
--- a/indoteknik_custom/models/product_pricelist.py
+++ b/indoteknik_custom/models/product_pricelist.py
@@ -14,13 +14,16 @@ class ProductPricelist(models.Model):
flashsale_option = fields.Selection([
('all', 'For All User'),
('registered_user', 'Only for Registered User')
- ], string='Flashsale Option')
+ ], string='Flash Sale Option')
banner_top = fields.Binary(string='Banner Top')
+ flashsale_tag = fields.Char(string='Flash Sale Tag')
def _remaining_time_in_second(self):
if not self.end_date:
return 0
- return round((self.end_date - datetime.now()).total_seconds())
+ remaining_time = (self.end_date - datetime.now()).total_seconds()
+ remaining_time = round(remaining_time)
+ return max(remaining_time, 0)
class ProductPricelistItem(models.Model):
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index acd592ab..82cb0432 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -154,15 +154,13 @@ class ProductTemplate(models.Model):
else:
template.have_promotion_program = False
- def _get_flash_sale_remaining_time(self):
+ def _get_active_flash_sale(self):
variant_ids = [x.id for x in self.product_variant_ids]
pricelist = self.env['product.pricelist'].search([
('is_flash_sale', '=', True),
('item_ids.product_id', 'in', variant_ids)
- ])
- if not pricelist:
- return 0
- return pricelist._remaining_time_in_second()
+ ], limit=1)
+ return pricelist
@api.model
def _calculate_rating_product(self, limit=1000, expiry_days=30, ids=False):