diff --git a/account_pdc_payment_report/__manifest__.py b/account_pdc_payment_report/__manifest__.py index e49087ffc..184b26eae 100644 --- a/account_pdc_payment_report/__manifest__.py +++ b/account_pdc_payment_report/__manifest__.py @@ -21,7 +21,7 @@ # ############################################################################## { - 'name': 'Payments Report', + 'name': 'PDC Payments Report', 'version': '10.0.1.0', 'author': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions', diff --git a/account_pdc_payment_report/__manifest__.py~ b/account_pdc_payment_report/__manifest__.py~ index efa4c2ed9..e49087ffc 100644 --- a/account_pdc_payment_report/__manifest__.py~ +++ b/account_pdc_payment_report/__manifest__.py~ @@ -27,7 +27,7 @@ 'company': 'Cybrosys Techno Solutions', 'website': 'http://www.cybrosys.com', 'category': 'Accounting', - 'summary': 'Report of Payments with filter for PDC type', + 'summary': 'Report of Payments with Filter for PDC Type', 'description': """ Report of Payments with filter for PDC type """, 'depends': ['account_check_printing', 'account_pdc'], 'data': [ diff --git a/website_coupon/README.rst b/website_coupon/README.rst new file mode 100644 index 000000000..3c603cce5 --- /dev/null +++ b/website_coupon/README.rst @@ -0,0 +1,17 @@ +Website Coupon Code v10 +======================= +Manage Website Coupon Codes & Its Operations + +Features +======== + +* Create and configure vouchers for providing a discount. +* 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. + + +Credits +======= +Cybrosys Techno Solutions, diff --git a/website_coupon/__init__.py b/website_coupon/__init__.py new file mode 100644 index 000000000..e4d608c06 --- /dev/null +++ b/website_coupon/__init__.py @@ -0,0 +1,25 @@ +# -*- 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 models +import controllers diff --git a/website_coupon/__manifest__.py b/website_coupon/__manifest__.py new file mode 100644 index 000000000..4de275ff9 --- /dev/null +++ b/website_coupon/__manifest__.py @@ -0,0 +1,42 @@ +# -*- 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 . +# +############################################################################## +{ + 'name': 'Website Coupon Code', + 'version': '10.0.1.0.0', + 'category': 'Website', + 'sequence': 56, + 'summary': 'Manage Website Coupon Codes & Its Operations', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'http://www.cybrosys.com', + 'depends': ['sale', 'website_sale'], + 'data': [ + 'data/product_data.xml', + 'views/gift_voucher.xml', + 'views/applied_coupons.xml', + 'views/templates.xml', + ], + 'installable': True, + 'license': 'LGPL-3', + 'auto_install': False, +} diff --git a/website_coupon/controllers/__init__.py b/website_coupon/controllers/__init__.py new file mode 100644 index 000000000..016e5ec5d --- /dev/null +++ b/website_coupon/controllers/__init__.py @@ -0,0 +1,24 @@ +# -*- 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 new file mode 100644 index 000000000..6f0bf75c6 --- /dev/null +++ b/website_coupon/controllers/main.py @@ -0,0 +1,138 @@ +# -*- 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 +from datetime import datetime +from dateutil import parser + + +class WebsiteCoupon(http.Controller): + + @http.route(['/shop/cart'], type='http', auth="public", website=True) + def cart(self, **post): + """This function is overwritten because we need to pass the value 'coupon_not_available' + to the template, inorder to show the error message to the user that, 'this coupon is not available'. """ + + order = request.website.sale_get_order() + if order: + from_currency = order.company_id.currency_id + to_currency = order.pricelist_id.currency_id + compute_currency = lambda price: from_currency.compute(price, to_currency) + else: + compute_currency = lambda price: price + + values = { + 'website_sale_order': order, + 'compute_currency': compute_currency, + 'suggested_products': [], + } + if order: + _order = order + if not request.env.context.get('pricelist'): + _order = order.with_context(pricelist=order.pricelist_id.id) + values['suggested_products'] = _order._cart_accessories() + + if post.get('type') == 'popover': + return request.render("website_sale.cart_popover", values) + + if post.get('code_not_available'): + 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) + def gift_coupon(self, promo_voucher, **post): + """This function will be executed when we click the apply button of the voucher code in the website. + It will verify the validity and availability of that coupon. If it can be applied, the coupon will be applied + and coupon balance will also be updated""" + + curr_user = request.env.user + coupon = request.env['gift.coupon'].sudo().search([('code', '=', promo_voucher)], limit=1) + flag = True + if coupon and coupon.total_avail > 0: + applied_coupons = request.env['partner.coupon'].sudo().search([('coupon', '=', promo_voucher), + ('partner_id', '=', curr_user.partner_id.id)], limit=1) + + # checking voucher date and limit for each user for this coupon--------------------- + if coupon.partner_id: + if curr_user.partner_id.id != coupon.partner_id.id: + flag = False + today = datetime.now().date() + if flag and applied_coupons.number < coupon.limit and today <= parser.parse(coupon.voucher.expiry_date).date(): + # checking coupon validity --------------------------- + # checking date of coupon ------------ + if coupon.start_date and coupon.end_date: + if today < parser.parse(coupon.start_date).date() or today > parser.parse(coupon.end_date).date(): + flag = False + elif coupon.start_date: + if today < parser.parse(coupon.start_date).date(): + flag = False + elif coupon.end_date: + if today > parser.parse(coupon.end_date).date(): + flag = False + else: + flag = False + else: + flag = False + if flag: + product_id = coupon.voucher.product_id + voucher_val = coupon.voucher_val + type = coupon.type + coupon_product = request.env['product.product'].sudo().search([('name', '=', 'Gift Coupon')], limit=1) + if coupon_product: + order = request.website.sale_get_order(force_create=1) + flag_product = False + for line in order.order_line: + 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 + for line in order.order_line: + amount += line.product_uom_qty * line.price_unit + amount_final = (voucher_val/100) * amount + 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) + + # 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})]}) + else: + applied_coupons.write({'number': applied_coupons.number + 1}) + else: + return request.redirect("/shop/cart?coupon_not_available=1") + + return request.redirect("/shop/cart") diff --git a/website_coupon/data/product_data.xml b/website_coupon/data/product_data.xml new file mode 100644 index 000000000..c5683902a --- /dev/null +++ b/website_coupon/data/product_data.xml @@ -0,0 +1,8 @@ + + + + Gift Coupon + + + + \ No newline at end of file diff --git a/website_coupon/models/__init__.py b/website_coupon/models/__init__.py new file mode 100644 index 000000000..5dc55fd1b --- /dev/null +++ b/website_coupon/models/__init__.py @@ -0,0 +1,24 @@ +# -*- 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 gift_voucher diff --git a/website_coupon/models/gift_voucher.py b/website_coupon/models/gift_voucher.py new file mode 100644 index 000000000..f58b3cf7e --- /dev/null +++ b/website_coupon/models/gift_voucher.py @@ -0,0 +1,84 @@ +# -*- 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 string +import random +from odoo import models, fields, api, _ +from odoo.exceptions import UserError + + +class GiftVoucher(models.Model): + _name = 'gift.voucher' + + name = fields.Char(string="Name", required=True) + product_id = fields.Many2one('product.product', string="Product", required=True) + 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) + + +class GiftCoupon(models.Model): + _name = 'gift.coupon' + + def get_code(self): + size = 7 + chars = string.ascii_uppercase + string.digits + return ''.join(random.choice(chars) for _ in range(size)) + + _sql_constraints = [ + ('name_uniq', 'unique (code)', "Code already exists !"), + ] + + name = fields.Char(string="Name", required=True) + code = fields.Char(string="Code", default=get_code) + voucher = fields.Many2one('gift.voucher', string="Voucher", required=True) + start_date = fields.Date(string="Start Date") + end_date = fields.Date(string="End Date") + partner_id = fields.Many2one('res.partner', string="Limit to a Single Partner") + limit = fields.Integer(string="Total Available For Each User", default=1) + total_avail = fields.Integer(string="Total Available", default=1) + + voucher_val = fields.Float(string="Voucher Value") + type = fields.Selection([ + ('fixed', 'Fixed Amount'), + ('percentage', 'Percentage'), + ], store=True, default='fixed') + + @api.onchange('voucher_val') + def check_val(self): + if self.voucher_val > self.voucher.max_value or self.voucher_val < self.voucher.min_value: + raise UserError(_("Please check the voucher value")) + + +class CouponPartner(models.Model): + _name = 'partner.coupon' + + partner_id = fields.Many2one('res.partner', string="Partner") + coupon = fields.Char(string="Coupon Applied") + number = fields.Integer(string="Number of Times Used") + + +class PartnerExtended(models.Model): + _inherit = 'res.partner' + + applied_coupon = fields.One2many('partner.coupon', 'partner_id', string="Coupons Applied") diff --git a/website_coupon/static/description/apply_coupon.png b/website_coupon/static/description/apply_coupon.png new file mode 100644 index 000000000..006f73d60 Binary files /dev/null and b/website_coupon/static/description/apply_coupon.png differ diff --git a/website_coupon/static/description/banner.jpg b/website_coupon/static/description/banner.jpg new file mode 100644 index 000000000..32924c0a7 Binary files /dev/null and b/website_coupon/static/description/banner.jpg differ diff --git a/website_coupon/static/description/coupon.png b/website_coupon/static/description/coupon.png new file mode 100644 index 000000000..f60126d5c Binary files /dev/null and b/website_coupon/static/description/coupon.png differ diff --git a/website_coupon/static/description/cybro_logo.png b/website_coupon/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/website_coupon/static/description/cybro_logo.png differ diff --git a/website_coupon/static/description/enable_voucher.png b/website_coupon/static/description/enable_voucher.png new file mode 100644 index 000000000..94c8a9663 Binary files /dev/null and b/website_coupon/static/description/enable_voucher.png differ diff --git a/website_coupon/static/description/history.png b/website_coupon/static/description/history.png new file mode 100644 index 000000000..797f09961 Binary files /dev/null and b/website_coupon/static/description/history.png differ diff --git a/website_coupon/static/description/icon.png b/website_coupon/static/description/icon.png new file mode 100644 index 000000000..6a55fc088 Binary files /dev/null and b/website_coupon/static/description/icon.png differ diff --git a/website_coupon/static/description/index.html b/website_coupon/static/description/index.html new file mode 100644 index 000000000..7465bd809 --- /dev/null +++ b/website_coupon/static/description/index.html @@ -0,0 +1,140 @@ +
+
+

Website Coupon

+

..Manage Your Coupon Codes 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. +

+
+
+ +
+
+

Features

+
+

+ ☛ Create and configure vouchers for providing a discount. +

+

+ ☛ 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. +

+
+
+
+ +
+
+
+

Enable the voucher option from the website.

+
+ +
+

+ When we added some product to our cart, under the 'Customize' menu, we can see the 'Voucher Code' option. +

+
+
+
+ +
+
+
+

Apply the coupon by providing the secret code.

+
+ +
+

+ After enabling the 'Voucher Code' option, we can enter our coupon code. If that code is valid, + it will be applied to the order. +

+
+
+
+ +
+
+
+

Create and configure vouchers.

+
+ +
+

+ For creating a voucher, 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. +

+
+
+
+ +
+
+
+

Create and configure coupons and codes.

+
+ +
+

+ When we create the coupon, a unique, auto-generated and editable code will be there for each coupon. There are mainly + two types of coupons, fixed and percentage. The fixed type is used to deduct a fixed amount from the order. The + percentage type will deduct a certain percentage of amount from the order. +

+

The total number of available coupons + and the number of times one user can use this coupon can be set here. It is also possible to limit this coupon to a single customer, + i.e, only one customer can use this coupon. +

+
+
+
+ +
+
+
+

Coupon History.

+
+ +
+

+ Under the 'Coupon History' menu, we can see the details of coupons used by all the customers. +

+
+
+
+ +
+

Need Any Help?

+ +
\ No newline at end of file diff --git a/website_coupon/static/description/voucher.png b/website_coupon/static/description/voucher.png new file mode 100644 index 000000000..6b64b4152 Binary files /dev/null and b/website_coupon/static/description/voucher.png differ diff --git a/website_coupon/views/applied_coupons.xml b/website_coupon/views/applied_coupons.xml new file mode 100644 index 000000000..9bb13cb56 --- /dev/null +++ b/website_coupon/views/applied_coupons.xml @@ -0,0 +1,46 @@ + + + + + applied_coupons_form + res.partner + + + + + + + + + + + + + + + + + + Gift Coupon History + partner.coupon + + + + + + + + + + + Gift Coupons History + partner.coupon + ir.actions.act_window + form + + tree + + + + + \ No newline at end of file diff --git a/website_coupon/views/gift_voucher.xml b/website_coupon/views/gift_voucher.xml new file mode 100644 index 000000000..fd8164b65 --- /dev/null +++ b/website_coupon/views/gift_voucher.xml @@ -0,0 +1,121 @@ + + + + + Gift Voucher + gift.voucher + +
+ + + + + + + + + + + +
+
+
+ + + Gift Voucher + gift.voucher + + + + + + + + + + + + + Gift Coupon + gift.coupon + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + Gift Coupon + gift.coupon + + + + + + + + + + + + + + + + Gift Vouchers + gift.voucher + ir.actions.act_window + form + + tree,form + + + + Generate Gift Coupons + gift.coupon + ir.actions.act_window + form + + tree,form + + + + + +
+
\ No newline at end of file diff --git a/website_coupon/views/templates.xml b/website_coupon/views/templates.xml new file mode 100644 index 000000000..e5183e8d5 --- /dev/null +++ b/website_coupon/views/templates.xml @@ -0,0 +1,89 @@ + + + + + + \ No newline at end of file