summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 52f72729..d6b9fcfe 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -1,6 +1,6 @@
from odoo import fields, models, api
from datetime import datetime, timedelta
-from odoo.exceptions import AccessError, UserError, ValidationError
+from odoo.exceptions import UserError
import logging
import requests
import json
@@ -164,10 +164,13 @@ class ProductTemplate(models.Model):
template.have_promotion_program = False
def _get_active_flash_sale(self):
+ current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
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)
+ ('item_ids.product_id', 'in', variant_ids),
+ ('start_date', '<=', current_time),
+ ('end_date', '>=', current_time)
], limit=1)
return pricelist
@@ -264,8 +267,7 @@ class ProductTemplate(models.Model):
}
self.env['token.storage'].create([values])
return values
-
-
+
class ProductProduct(models.Model):
_inherit = "product.product"
web_price = fields.Float(
@@ -346,4 +348,4 @@ class ProductProduct(models.Model):
('start_date', '<=', current_time),
('end_date', '>=', current_time)
], limit=1)
- return pricelist \ No newline at end of file
+ return pricelist