diff --git a/website_coupon/README.rst b/website_coupon/README.rst index 3c603cce5..d3ed5c252 100644 --- a/website_coupon/README.rst +++ b/website_coupon/README.rst @@ -1,17 +1,35 @@ Website Coupon Code v10 ======================= -Manage Website Coupon Codes & Its Operations +Manage Website Coupon Codes for Products/Categories/All Products & Its Redeem Operations -Features -======== +Features(base version: 10.0.1) +============================== -* Create and configure vouchers for providing a discount. +* Create and configure vouchers for providing a discount for a single product. * Generate a unique code for each coupon. * Limit the usage of coupons by each user. * Provide a validity for the coupons. * History of coupons used by each customer. +Additional Features (version: 10.0.2) +===================================== + +* Create and configure vouchers for a category of products. +* Create and configure vouchers for all the products. +* The coupon cannot be applied, if the coupon value is greater than the total amount of an order. + +Installation +============ + +Just select it from available modules to install it, there is no need to extra installations. + +Configuration +============= + +After installing the module, go to sales and create vouchers from the vouchers menu. After voucher is created, we can +generate the coupons related to this voucher. Now go to website, go to cart and under the customize menu, enable the +voucher code option. Credits ======= -Cybrosys Techno Solutions, +Developer: Linto CT @ cybrosys, linto@cybrosys.in diff --git a/website_coupon/__init__.py b/website_coupon/__init__.py index e4d608c06..1ded18c1b 100644 --- a/website_coupon/__init__.py +++ b/website_coupon/__init__.py @@ -2,8 +2,8 @@ ############################################################################## # # Cybrosys Technologies Pvt. Ltd. -# Copyright (C) 2017-TODAY Cybrosys Technologies(). -# Author: Cybrosys Technologies() +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: LINTO C T() # you can modify it under the terms of the GNU LESSER # GENERAL PUBLIC LICENSE (LGPL v3), Version 3. # @@ -17,7 +17,7 @@ # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE # GENERAL PUBLIC LICENSE (LGPL v3) along with this program. -# If not, see . +# If not, see . # ############################################################################## diff --git a/website_coupon/__manifest__.py b/website_coupon/__manifest__.py index 075fffbc3..0654e27a5 100644 --- a/website_coupon/__manifest__.py +++ b/website_coupon/__manifest__.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- + ############################################################################## # # Cybrosys Technologies Pvt. Ltd. -# Copyright (C) 2017-TODAY Cybrosys Technologies(). -# Author: Cybrosys Technologies() +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: LINTO C T() # you can modify it under the terms of the GNU LESSER # GENERAL PUBLIC LICENSE (LGPL v3), Version 3. # @@ -17,19 +18,19 @@ # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE # GENERAL PUBLIC LICENSE (LGPL v3) along with this program. -# If not, see . +# If not, see . # ############################################################################## { 'name': 'Website Coupon Code', - 'version': '10.0.1.0.0', + 'version': '10.0.2.0', 'category': 'Website', 'sequence': 56, - 'summary': 'Manage Website Coupon Codes & Its Operations', + 'summary': 'Manage Website Coupon Codes for Products/Categories/All Products & Its Redeem Operations', 'author': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions', - 'website': 'http://www.cybrosys.com', 'depends': ['sale', 'website_sale'], + 'website': 'http://www.cybrosys.com', 'data': [ 'data/product_data.xml', 'views/gift_voucher.xml', @@ -37,7 +38,5 @@ 'views/templates.xml', ], 'installable': True, - 'images': ['static/description/banner.jpg'], - 'license': 'LGPL-3', 'auto_install': False, } diff --git a/website_coupon/controllers/__init__.py b/website_coupon/controllers/__init__.py index 016e5ec5d..bbd183e95 100644 --- a/website_coupon/controllers/__init__.py +++ b/website_coupon/controllers/__init__.py @@ -1,24 +1,3 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Cybrosys Technologies Pvt. Ltd. -# Copyright (C) 2017-TODAY Cybrosys Technologies(). -# Author: Cybrosys Technologies() -# you can modify it under the terms of the GNU LESSER -# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. -# -# It is forbidden to publish, distribute, sublicense, or sell copies -# of the Software or modified copies of the Software. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. -# -# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE -# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. -# If not, see . -# -############################################################################## import main diff --git a/website_coupon/controllers/main.py b/website_coupon/controllers/main.py index 6f0bf75c6..72bf1b616 100644 --- a/website_coupon/controllers/main.py +++ b/website_coupon/controllers/main.py @@ -1,25 +1,4 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Cybrosys Technologies Pvt. Ltd. -# Copyright (C) 2017-TODAY Cybrosys Technologies(). -# Author: Cybrosys Technologies() -# you can modify it under the terms of the GNU LESSER -# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. -# -# It is forbidden to publish, distribute, sublicense, or sell copies -# of the Software or modified copies of the Software. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. -# -# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE -# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. -# If not, see . -# -############################################################################## from odoo import http, tools, _ from odoo.http import request @@ -60,7 +39,6 @@ class WebsiteCoupon(http.Controller): values['code_not_available'] = post.get('code_not_available') elif post.get('coupon_not_available'): values['coupon_not_available'] = post.get('coupon_not_available') - return request.render("website_sale.cart", values) @http.route(['/shop/gift_coupon'], type='http', auth="public", website=True) @@ -98,7 +76,7 @@ class WebsiteCoupon(http.Controller): else: flag = False if flag: - product_id = coupon.voucher.product_id + voucher_type = coupon.voucher.voucher_type voucher_val = coupon.voucher_val type = coupon.type coupon_product = request.env['product.product'].sudo().search([('name', '=', 'Gift Coupon')], limit=1) @@ -109,29 +87,50 @@ class WebsiteCoupon(http.Controller): if line.product_id.name == 'Gift Coupon': flag = False break - if line.product_id.name == product_id.name: - flag_product = True - if flag and flag_product: - if type == 'fixed': - res = coupon_product.product_tmpl_id.write({'list_price': -voucher_val}) - elif type == 'percentage': - amount = 0 + if flag and order.order_line: + if voucher_type == 'product': + # the voucher type is product ---------------------------- + categ_id = coupon.voucher.product_id for line in order.order_line: - amount += line.product_uom_qty * line.price_unit - amount_final = (voucher_val/100) * amount + if line.product_id.name == categ_id.name: + flag_product = True + elif voucher_type == 'category': + # the voucher type is category ---------------------------- + product_id = coupon.voucher.product_categ + for line in order.order_line: + if line.product_id.categ_id.name == product_id.name: + flag_product = True + elif voucher_type == 'all': + # the voucher is applicable to all products ---------------------------- + flag_product = True + if flag_product: + # the voucher is applicable -------------------------------------- + if type == 'fixed': + # coupon type is 'fixed'-------------------------------------- + if voucher_val < order.amount_total: + res = coupon_product.product_tmpl_id.write({'list_price': -voucher_val}) + else: + return request.redirect("/shop/cart?coupon_not_available=3") + elif type == 'percentage': + # coupon type is percentage ------------------------------------- + amount_final = (voucher_val/100) * order.amount_total res = 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) + value = order._cart_update(product_id=coupon_product.id, set_qty=1, add_qty=1) - # updating coupon balance-------------- - total = coupon.total_avail - 1 - coupon.write({'total_avail': total}) - # creating a record for this partner, i.e he is used this coupen once----------- - if not applied_coupons: - res = curr_user.partner_id.write({'applied_coupon': [(0, 0, {'partner_id': curr_user.partner_id.id, - 'coupon': coupon.code, - 'number': 1})]}) + # updating coupon balance-------------- + total = coupon.total_avail - 1 + coupon.write({'total_avail': total}) + # creating a record for this partner, i.e he is used this coupon once----------- + if not applied_coupons: + res = curr_user.partner_id.write({'applied_coupon': [(0, 0, {'partner_id': curr_user.partner_id.id, + 'coupon': coupon.code, + 'number': 1})]}) + else: + applied_coupons.write({'number': applied_coupons.number + 1}) else: - applied_coupons.write({'number': applied_coupons.number + 1}) + return request.redirect("/shop/cart?coupon_not_available=1") + else: + return request.redirect("/shop/cart?coupon_not_available=2") else: return request.redirect("/shop/cart?coupon_not_available=1") diff --git a/website_coupon/data/product_data.xml b/website_coupon/data/product_data.xml index c5683902a..bd5871987 100644 --- a/website_coupon/data/product_data.xml +++ b/website_coupon/data/product_data.xml @@ -2,7 +2,6 @@ Gift Coupon - \ No newline at end of file diff --git a/website_coupon/models/__init__.py b/website_coupon/models/__init__.py index 5dc55fd1b..d91b1374f 100644 --- a/website_coupon/models/__init__.py +++ b/website_coupon/models/__init__.py @@ -2,8 +2,8 @@ ############################################################################## # # Cybrosys Technologies Pvt. Ltd. -# Copyright (C) 2017-TODAY Cybrosys Technologies(). -# Author: Cybrosys Technologies() +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: LINTO C T() # you can modify it under the terms of the GNU LESSER # GENERAL PUBLIC LICENSE (LGPL v3), Version 3. # @@ -17,8 +17,7 @@ # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE # GENERAL PUBLIC LICENSE (LGPL v3) along with this program. -# If not, see . +# If not, see . # ############################################################################## - import gift_voucher diff --git a/website_coupon/models/gift_voucher.py b/website_coupon/models/gift_voucher.py index f58b3cf7e..467b01ee9 100644 --- a/website_coupon/models/gift_voucher.py +++ b/website_coupon/models/gift_voucher.py @@ -2,8 +2,8 @@ ############################################################################## # # Cybrosys Technologies Pvt. Ltd. -# Copyright (C) 2017-TODAY Cybrosys Technologies(). -# Author: Cybrosys Technologies() +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: LINTO C T() # you can modify it under the terms of the GNU LESSER # GENERAL PUBLIC LICENSE (LGPL v3), Version 3. # @@ -17,10 +17,9 @@ # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE # GENERAL PUBLIC LICENSE (LGPL v3) along with this program. -# If not, see . +# If not, see . # ############################################################################## - import string import random from odoo import models, fields, api, _ @@ -31,7 +30,15 @@ class GiftVoucher(models.Model): _name = 'gift.voucher' name = fields.Char(string="Name", required=True) - product_id = fields.Many2one('product.product', string="Product", required=True) + voucher_type = fields.Selection( + selection=[ + ('product', 'Product'), + ('category', 'Product Category'), + ('all', 'All Products'), + ], string="Applicable on ", default='product' + ) + product_id = fields.Many2one('product.product', string="Product") + product_categ = fields.Many2one('product.category', string="Product Category") min_value = fields.Integer(string="Minimum Voucher Value", required=True) max_value = fields.Integer(string="Maximum Voucher Value", required=True) expiry_date = fields.Date(string="Expiry Date", required=True) diff --git a/website_coupon/static/description/index.html b/website_coupon/static/description/index.html index 7465bd809..2aa911697 100644 --- a/website_coupon/static/description/index.html +++ b/website_coupon/static/description/index.html @@ -1,10 +1,10 @@

Website Coupon

-

..Manage Your Coupon Codes Simply..

+

..Manage Your Coupons Simply..

Cybrosys Technologies , www.cybrosys.com

-

+

This module by Cybrosys Technologies allows us to manage our customers in a better way by providing discount coupons to our special customers, and thereby increase the sales.

@@ -16,7 +16,7 @@

Features

- ☛ Create and configure vouchers for providing a discount. + ☛ Create and configure vouchers for providing a discount based on product, product category or for all products.

☛ Generate a unique code for each coupon. @@ -57,9 +57,19 @@

After enabling the 'Voucher Code' option, we can enter our coupon code. If that code is valid, - it will be applied to the order. + it will be applied to the order. The validation is based on the expiry date of the voucher, + the voucher type, coupon code entered, coupon balance, etc. + The total amount of an order can't be zero or less than, zero. After we have + entered the coupon code and pressed the apply button, the system will check the amount after + applying the coupon specified is greater than zero or not. If not, we cannot apply this coupon to this order. + In this case we will see a notification saying that this coupon is not applicable.

+
+
+ +
+
@@ -67,14 +77,34 @@

Create and configure vouchers.

-
- -

- For creating a voucher, we need to specify a product, that means, this voucher will be applicable only + For creating a voucher, there are three options. We can create a voucher for a single product or a product category + or for the complete products. For the first option, we need to specify a product, that means, this voucher will be applicable only if the customer has selected this product in his order. The minimum and maximum voucher values can be set here. The expiry date indicates the validity of this voucher.

+

+ For creating voucher for a product category, we need to select a category. In + this case, this voucher will be applicable only if the cart contains products from this category. +

+

+ The third option can be used to provide discounts for all the products. +

+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
@@ -113,28 +143,28 @@ -
-

Need Any Help?

- +
+

Need Any Help?

+
\ No newline at end of file diff --git a/website_coupon/static/description/unable_to_update.png b/website_coupon/static/description/unable_to_update.png new file mode 100644 index 000000000..ea912ede1 Binary files /dev/null and b/website_coupon/static/description/unable_to_update.png differ diff --git a/website_coupon/static/description/voucher.png b/website_coupon/static/description/voucher.png deleted file mode 100644 index 6b64b4152..000000000 Binary files a/website_coupon/static/description/voucher.png and /dev/null differ diff --git a/website_coupon/static/description/voucher_all.png b/website_coupon/static/description/voucher_all.png new file mode 100644 index 000000000..9455ea520 Binary files /dev/null and b/website_coupon/static/description/voucher_all.png differ diff --git a/website_coupon/static/description/voucher_category.png b/website_coupon/static/description/voucher_category.png new file mode 100644 index 000000000..61810282d Binary files /dev/null and b/website_coupon/static/description/voucher_category.png differ diff --git a/website_coupon/static/description/voucher_product.png b/website_coupon/static/description/voucher_product.png new file mode 100644 index 000000000..1758a552f Binary files /dev/null and b/website_coupon/static/description/voucher_product.png differ diff --git a/website_coupon/views/gift_voucher.xml b/website_coupon/views/gift_voucher.xml index fd8164b65..52562f663 100644 --- a/website_coupon/views/gift_voucher.xml +++ b/website_coupon/views/gift_voucher.xml @@ -10,7 +10,11 @@ - + + + diff --git a/website_coupon/views/templates.xml b/website_coupon/views/templates.xml index e5183e8d5..fdf761f0a 100644 --- a/website_coupon/views/templates.xml +++ b/website_coupon/views/templates.xml @@ -7,7 +7,15 @@ Have a voucher code? Fill this field and apply.

-

This gift code is not available

+ +

This gift code is not available

+
+ +

This gift code is not available

+
+ +

The discount amount is too large

+
@@ -84,6 +92,7 @@ + \ No newline at end of file