| 
						
						
						
					 | 
					@ -1,9 +1,9 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					# -*- coding: utf-8 -*- | 
					 | 
					 | 
					# -*- coding: utf-8 -*- | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from odoo import http, tools, _ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from odoo.http import request | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from datetime import datetime | 
					 | 
					 | 
					from datetime import datetime | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from dateutil import parser | 
					 | 
					 | 
					from dateutil import parser | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					from odoo import http, tools, _ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					from odoo.http import request | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					class WebsiteCoupon(http.Controller): | 
					 | 
					 | 
					class WebsiteCoupon(http.Controller): | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -108,32 +108,32 @@ class WebsiteCoupon(http.Controller): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        if type == 'fixed': | 
					 | 
					 | 
					                        if type == 'fixed': | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            # coupon type is 'fixed'-------------------------------------- | 
					 | 
					 | 
					                            # coupon type is 'fixed'-------------------------------------- | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            if voucher_val < order.amount_total: | 
					 | 
					 | 
					                            if voucher_val < order.amount_total: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                                res = coupon_product.product_tmpl_id.write({'list_price': -voucher_val}) | 
					 | 
					 | 
					                                coupon_product.product_tmpl_id.write({'list_price': -voucher_val}) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            else: | 
					 | 
					 | 
					                            else: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                return request.redirect("/shop/cart?coupon_not_available=3") | 
					 | 
					 | 
					                                return request.redirect("/shop/cart?coupon_not_available=3") | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        elif type == 'percentage': | 
					 | 
					 | 
					                        elif type == 'percentage': | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            # coupon type is percentage ------------------------------------- | 
					 | 
					 | 
					                            # coupon type is percentage ------------------------------------- | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            amount_final = 0 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            if voucher_type == 'product': | 
					 | 
					 | 
					                            if voucher_type == 'product': | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                for line in order.order_line: | 
					 | 
					 | 
					                                for line in order.order_line: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                    if line.product_id.name == categ_id.name: | 
					 | 
					 | 
					                                    if line.product_id.name == categ_id.name: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                        amount_final = (voucher_val / 100) * line.price_total | 
					 | 
					 | 
					                                        amount_final = (voucher_val / 100) * line.price_total | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                        break | 
					 | 
					 | 
					                                        break | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            elif voucher_type == 'category': | 
					 | 
					 | 
					                            elif voucher_type == 'category': | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                amount_final = 0 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                for line in order.order_line: | 
					 | 
					 | 
					                                for line in order.order_line: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                    if line.product_id.categ_id.name == product_id.name: | 
					 | 
					 | 
					                                    if line.product_id.categ_id.name == product_id.name: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                        amount_final += (voucher_val / 100) * line.price_total | 
					 | 
					 | 
					                                        amount_final += (voucher_val / 100) * line.price_total | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            elif voucher_type == 'all': | 
					 | 
					 | 
					                            elif voucher_type == 'all': | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                amount_final = (voucher_val/100) * order.amount_total | 
					 | 
					 | 
					                                amount_final = (voucher_val/100) * order.amount_total | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                        res = coupon_product.product_tmpl_id.write({'list_price': -amount_final}) | 
					 | 
					 | 
					                            coupon_product.product_tmpl_id.write({'list_price': -amount_final}) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                        value = order._cart_update(product_id=coupon_product.id, set_qty=1, add_qty=1) | 
					 | 
					 | 
					                        order._cart_update(product_id=coupon_product.id, set_qty=1, add_qty=1) | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                        # updating coupon balance-------------- | 
					 | 
					 | 
					                        # updating coupon balance-------------- | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        total = coupon.total_avail - 1 | 
					 | 
					 | 
					                        total = coupon.total_avail - 1 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        coupon.write({'total_avail': total}) | 
					 | 
					 | 
					                        coupon.write({'total_avail': total}) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        # creating a record for this partner, i.e he is used this coupon once----------- | 
					 | 
					 | 
					                        # creating a record for this partner, i.e he is used this coupon once----------- | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        if not applied_coupons: | 
					 | 
					 | 
					                        if not applied_coupons: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                            res = curr_user.partner_id.write({'applied_coupon': [(0, 0, {'partner_id': curr_user.partner_id.id, | 
					 | 
					 | 
					                            curr_user.partner_id.write({'applied_coupon': [(0, 0, {'partner_id': curr_user.partner_id.id, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                                                                                         'coupon': coupon.code, | 
					 | 
					 | 
					                                                                                         'coupon': coupon.code, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                                                                         'number': 1})]}) | 
					 | 
					 | 
					                                                                                         'number': 1})]}) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        else: | 
					 | 
					 | 
					                        else: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |