summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-08-29 11:15:58 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-08-29 11:15:58 +0700
commita1400f8ccdfb829a4193c5e8d3f910211e0d5830 (patch)
tree4211e0c4acbffba80f56c2c8e15085c22bbfadbc /indoteknik_custom/models/product_template.py
parent203feb6018c55c108c31f4c0e03d38a8f39af52e (diff)
parent6ed2316f6aa446bcd5bc7e6cd4d0c0a1136096dd (diff)
Merge branch 'change/feature/sync-solr' into production
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