summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/website_user_cart.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py
index a361b4e1..b36e9e38 100644
--- a/indoteknik_custom/models/website_user_cart.py
+++ b/indoteknik_custom/models/website_user_cart.py
@@ -140,7 +140,7 @@ class WebsiteUserCart(models.Model):
carts_to_remind = self.search([('user_id', '=', user)])
if latest_cart and not latest_cart.is_reminder:
for cart in carts_to_remind:
- if not cart.program_line_id:
+ if not cart.program_line_id and not 'BOM' in cart.product_id.default_code:
cart.is_selected = True
cart.is_reminder = True
template = self.env.ref('indoteknik_custom.mail_template_user_cart_reminder_to_checkout')
@@ -149,11 +149,12 @@ class WebsiteUserCart(models.Model):
def calculate_discount(self, user_id):
carts = self.search([('user_id', '=', user_id)])
voucher = self.env['voucher'].browse(146)
- total_discount = 0.01
+ total_discount = 0.0
total_voucher = 0.0
subtotal_website = 0.0
for cart in carts:
+ check = cart.check_product_flashsale(cart.product_id.id)
product_manufacture = cart.product_id.x_manufacture.id
product_price = cart.get_price_website(cart.product_id.id)
subtotal = product_price['price'] * cart.qty
@@ -173,8 +174,9 @@ class WebsiteUserCart(models.Model):
product_discount = subtotal_promo if cart.program_line_id else subtotal
voucher_product = subtotal * (discount_amount / 100.0)
- total_discount += product_discount
- total_voucher += voucher_product
+ total_discount += product_discount
+ if check == False and cart.product_id.default_code and not 'BOM' in cart.product_id.default_code:
+ total_voucher += voucher_product
if total_discount > 0:
ppn = subtotal_website * 0.11
@@ -186,6 +188,16 @@ class WebsiteUserCart(models.Model):
'grand_total': self.format_currency(total_discount + ppn)
}
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)
+ if found_product:
+ return {
+ 'is_flashsale': True,
+ 'price': found_product.fixed_price
+ }
+ return False
def get_data_promo(self, program_line_id):
program_line_product = self.env['promotion.product'].search([