From 1e1e3226e84b6e8d7a628855051e0768b7d4e71e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 30 Jul 2024 09:50:36 +0700 Subject: cr reminder email checkout --- indoteknik_custom/models/website_user_cart.py | 20 +++++++++++++---- indoteknik_custom/views/website_user_cart.xml | 31 +++++++++++++++++++++++++++ 2 files changed, 47 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([ diff --git a/indoteknik_custom/views/website_user_cart.xml b/indoteknik_custom/views/website_user_cart.xml index 97e8cf02..7303a221 100755 --- a/indoteknik_custom/views/website_user_cart.xml +++ b/indoteknik_custom/views/website_user_cart.xml @@ -136,6 +136,7 @@ % set product_price = cart.get_price_website(cart.product_id.id) % set product_template_id = cart.product_id.product_tmpl_id.id % set subtotal = product_price['price'] * cart.qty + % set flashsale = cart.check_product_flashsale(cart.product_id.id) % if cart.program_line_id: % set promo, free_product = cart.get_data_promo(cart.program_line_id.id) @@ -212,6 +213,36 @@ No promotion available for this product. % endif + + % elif flashsale['is_flashsale'] == True: + +
+
+
+ ${cart.product_id.name} +
+
+
${cart.product_id.name}
+
+
+ Rp ${cart.format_currency(product_price['price'])} +
+
+ Rp ${cart.format_currency(flashsale['price'])} +
+
+
+ ${cart.product_id.default_code} | Berat barang: ${cart.product_id.weight} Kg +
+
+
+ +
+
+
+ % else:
-- cgit v1.2.3