diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-07-30 09:50:36 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-07-30 09:50:36 +0700 |
| commit | 1e1e3226e84b6e8d7a628855051e0768b7d4e71e (patch) | |
| tree | a21130f87a919376dabf27f57b886a844cea3fa4 | |
| parent | f369c55dc0b696449eddad6cd30f2db285b49542 (diff) | |
cr reminder email checkout
| -rw-r--r-- | indoteknik_custom/models/website_user_cart.py | 20 | ||||
| -rwxr-xr-x | 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) <tr> % 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. </td> % endif + + % elif flashsale['is_flashsale'] == True: + <td style="border: 1px solid #dddddd; padding: 8px;"> + <div class="container text-center"> + <div style="display: flex; gap: 20px; align-items: center; margin-top: 8px;"> + <div class="col-3"> + <img src="${base_url}api/image/product.template/image_512/${product_template_id}" + alt="${cart.product_id.name}" width="120" height="120" + style="object-fit: fill; object-position: center;"/> + </div> + <div class="col-6"> + <div style="font-weight: 600; margin-bottom: 8px;">${cart.product_id.name}</div> + <div style="display: flex; gap: 20px; align-items: center; margin-bottom: 8px;"> + <div style="color: grey; text-decoration: line-through; margin-right: 10px;"> + Rp ${cart.format_currency(product_price['price'])} + </div> + <div style="color: red; font-weight: bold;"> + Rp ${cart.format_currency(flashsale['price'])} + </div> + </div> + <div style="color: grey;"> + ${cart.product_id.default_code} | Berat barang: ${cart.product_id.weight} Kg + </div> + </div> + <div class="col-3"> + <button type="button" class="btn btn-outline-secondary" style="margin-left: 11rem; margin-top: 2.5rem;">${cart.format_integer(cart.qty)}</button> + </div> + </div> + </div> + </td> % else: <td style="border: 1px solid #dddddd; padding: 8px;"> <div class="container text-center"> |
