summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-07-30 13:41:44 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-07-30 13:41:44 +0700
commit2bb2591a61f62d941899d440e6ef75af1a792d79 (patch)
tree1083cef1c351deaef03d20fb0203080e626d2dd8
parent5dd31ffbce1fef2e29a3d17bafd13569763805e8 (diff)
testing email reminder checkout
-rw-r--r--indoteknik_custom/models/website_user_cart.py62
1 files changed, 49 insertions, 13 deletions
diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py
index b36e9e38..c6fa2bf7 100644
--- a/indoteknik_custom/models/website_user_cart.py
+++ b/indoteknik_custom/models/website_user_cart.py
@@ -133,7 +133,7 @@ class WebsiteUserCart(models.Model):
def action_mail_reminder_to_checkout(self):
# user_ids = self.search([]).mapped('user_id')
- user_ids = [101]
+ user_ids = [1102]
for user in user_ids:
latest_cart = self.search([('user_id', '=', user), ('is_reminder', '=', False)], order='create_date desc', limit=1)
@@ -158,13 +158,16 @@ class WebsiteUserCart(models.Model):
product_manufacture = cart.product_id.x_manufacture.id
product_price = cart.get_price_website(cart.product_id.id)
subtotal = product_price['price'] * cart.qty
- subtotal_website += product_price['price']
subtotal_promo = 0.0
if cart.program_line_id:
subtotal_website += cart.program_line_id.price
subtotal_promo = cart.program_line_id.price * cart.qty
-
+ elif check['is_flashsale']:
+ subtotal_website += check['price']
+ subtotal_promo = check['price'] * cart.qty
+ else:
+ subtotal_website += product_price['price']
discount_amount = 0.0
if product_manufacture:
for line in voucher.voucher_line:
@@ -173,13 +176,14 @@ class WebsiteUserCart(models.Model):
break
product_discount = subtotal_promo if cart.program_line_id else subtotal
- voucher_product = subtotal * (discount_amount / 100.0)
total_discount += product_discount
- if check == False and cart.product_id.default_code and not 'BOM' in cart.product_id.default_code:
+ if check['is_flashsale'] == False and cart.product_id.default_code and not 'BOM' in cart.product_id.default_code:
+ product_discount = subtotal - (subtotal * (discount_amount / 100.0))
+ voucher_product = subtotal * (discount_amount / 100.0)
total_voucher += voucher_product
if total_discount > 0:
- ppn = subtotal_website * 0.11
+ ppn = total_discount * 0.11
return {
'total_discount': self.format_currency(total_discount),
'total_voucher': self.format_currency(total_voucher),
@@ -190,14 +194,46 @@ class WebsiteUserCart(models.Model):
return self.format_currency(0.0)
def check_product_flashsale(self, product_id):
- product = product_id
- found_product = self.env['product.pricelist.item'].search([('product_id', '=', product_id), ('pricelist_id.is_flash_sale', '=', True)], limit=1)
+ product = product_id
+ current_time = datetime.utcnow()
+ found_product = self.env['product.pricelist.item'].search([('product_id', '=', product_id), ('pricelist_id.is_flash_sale', '=', True)])
+
if found_product:
- return {
- 'is_flashsale': True,
- 'price': found_product.fixed_price
- }
- return False
+ for found in found_product:
+ pricelist_flashsale = found.pricelist_id
+
+ if pricelist_flashsale.start_date <= current_time <= pricelist_flashsale.end_date:
+ return {
+ 'is_flashsale': True,
+ 'price': found.fixed_price
+ }
+ else:
+ return {
+ 'is_flashsale': False
+ }
+
+ return {
+ 'is_flashsale': False
+ }
+
+
+ # if found_product:
+ # start_date = found_product.pricelist_id.start_date
+ # end_date = found_product.pricelist_id.end_date
+ # current_time = datetime.now()
+
+ # if start_date and end_date:
+ # if start_date >= current_time and end_date <= current_time:
+ # return {
+ # 'is_flashsale': False
+ # }
+ # return {
+ # 'is_flashsale': True,
+ # 'price': found_product.fixed_price
+ # }
+ # return {
+ # 'is_flashsale': False
+ # }
def get_data_promo(self, program_line_id):
program_line_product = self.env['promotion.product'].search([