diff --git a/website_subscription_package/README.rst b/website_subscription_package/README.rst new file mode 100644 index 000000000..71406da0e --- /dev/null +++ b/website_subscription_package/README.rst @@ -0,0 +1,48 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Website Subscription Package Management +======================================= +This Module Create Subscription for A Product From Website. + +Configuration +============= +* No Additional configuration is needed. + +License +------- +Affero General Public License v3.0 (AGPL v3) +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developer: (V16) Anagha S, + (V15) Sabeel B +Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/website_subscription_package/__init__.py b/website_subscription_package/__init__.py new file mode 100644 index 000000000..ee471b8d4 --- /dev/null +++ b/website_subscription_package/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import controllers +from . import models diff --git a/website_subscription_package/__manifest__.py b/website_subscription_package/__manifest__.py new file mode 100644 index 000000000..ced9a2a85 --- /dev/null +++ b/website_subscription_package/__manifest__.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +{ + 'name': 'Website Subscription Package Management', + 'version': '15.0.1.0.0', + 'category': 'Sales, Website', + 'summary': 'Subscription Package Management Through website', + 'description': """This Module Create Subscription for A Product From + Website""", + 'author': 'Cybrosys Techno solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['subscription_package', 'website_sale'], + 'data': [ + 'data/mail_template_data.xml', + 'views/product_product_views.xml', + 'views/product_template_views.xml', + 'views/subscription_package_views.xml', + 'views/sale_order_views.xml', + 'views/portal_templates.xml', + 'views/website_product_subscription_template.xml', + ], + 'assets': { + 'web.assets_frontend': [ + 'website_subscription_package/static/src/js/website_sale.js', + ], + }, + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/website_subscription_package/controllers/__init__.py b/website_subscription_package/controllers/__init__.py new file mode 100644 index 000000000..bed3f4f20 --- /dev/null +++ b/website_subscription_package/controllers/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import portal +from . import website_subscription_package diff --git a/website_subscription_package/controllers/portal.py b/website_subscription_package/controllers/portal.py new file mode 100644 index 000000000..d509f7e8a --- /dev/null +++ b/website_subscription_package/controllers/portal.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import _, http +from odoo.exceptions import AccessError +from odoo.http import request +from odoo.addons.portal.controllers import portal +from odoo.addons.portal.controllers.portal import pager as portal_pager + + +class SubscriptionCustomerPortal(portal.CustomerPortal): + """A class representing a subscription-based customer portal. + This class extends the functionality of the base CustomerPortal class to + provide features specific to subscription management and interactions.""" + + def _prepare_home_portal_values(self, counters): + """Values for /my & /my/home routes template rendering. + Includes the record count for subscription order.""" + values = super()._prepare_home_portal_values(counters) + if 'subscription_count' in counters: + subscription_count = request.env[ + 'subscription.package'].sudo().search_count( + [('partner_id', '=', request.env.user.partner_id.id), + ('is_closed', '=', False)]) + values['subscription_count'] = subscription_count + return values + + @http.route('/my/subscription_order', + type='http', auth='user', website=True) + def portal_my_subscription_orders(self, page=1, sortby=None, filterby=None, + search=None, search_in='all', + groupby='none'): + """Values for /my/subscription_order routes template rendering.""" + values = self._prepare_portal_layout_values() + subscription = request.env['subscription.package'].sudo() + domain = [('partner_id', '=', request.env.user.partner_id.id), + ('is_closed', '=', False)] + if not sortby: + sortby = 'start_date' + subscription_count = subscription.search_count(domain) + pager = portal_pager( + url="/my/subscription_order", + url_args={'sortby': sortby, 'search_in': search_in, + 'search': search, 'groupby': groupby}, + total=subscription_count, page=page, step=self._items_per_page) + subscription_order = subscription.search( + domain, limit=self._items_per_page, offset=pager['offset']) + grouped_subscriptions = False + values.update({ + 'subscriptions': subscription_order, + 'grouped_subscriptions': grouped_subscriptions, + 'page_name': 'Subscription', + 'pager': pager, + 'default_url': '/my/subscription_order', + 'search_in': search_in, + 'search': search, + 'sortby': sortby, + 'groupby': groupby, + 'filterby': filterby}) + return request.render( + "website_subscription_package.portal_my_subscriptions", values) + + @http.route( + ['/my/subscription_order/', + '/my/subscription_order/id=/state='], + type='http', auth="user", website=True) + def subscription_page(self, subscription=None, state=None): + """Render subscription page.""" + subscription = request.env['subscription.package'].sudo().browse( + subscription) + if state == 'Draft': + subscription.button_start_date() + try: + subscription.check_access_rights('read') + subscription.check_access_rule('read') + except AccessError: + return request.website.render("website.403") + return request.render( + "website_subscription_package.subscription_page", { + 'subscription': subscription.sudo()}) diff --git a/website_subscription_package/controllers/website_subscription_package.py b/website_subscription_package/controllers/website_subscription_package.py new file mode 100755 index 000000000..b5278223a --- /dev/null +++ b/website_subscription_package/controllers/website_subscription_package.py @@ -0,0 +1,133 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import fields, http +from odoo.http import request +from odoo.addons.website.controllers.main import QueryURL +from odoo.addons.website_sale.controllers.main import WebsiteSale +from odoo.tools.json import scriptsafe as json_scriptsafe + + +class WebsiteSaleSubscription(WebsiteSale): + """Inherited class of website sale.""" + + @http.route(['/shop/'], + type='http', auth="public", website=True) + def product(self, product, category='', search=''): + """Add Subscription plan and recurrence period for subscription + Product in website.""" + product_context = dict(request.env.context, active_id=product.id) + product_category = request.env['product.public.category'] + if category: + category = product_category.browse(int(category)).exists() + attrib_list = request.httprequest.args.getlist('attrib') + attrib_values = [map(int, value.split("-")) for value in attrib_list if + value] + attrib_set = {value[1] for value in attrib_values} + keep = QueryURL('/shop', category=category and category.id, + search=search, attrib=attrib_list) + categories = product_category.search([('parent_id', '=', False)]) + price_list = request.website.get_current_pricelist() + from_currency = request.env.user.company_id.currency_id + to_currency = price_list.currency_id + compute_currency = lambda price: from_currency.compute(price, + to_currency) + subscription_plan = [] + recurrence_period = [] + if not product_context.get('pricelist'): + product_context['pricelist'] = price_list.id + product = product.with_context(product_context) + if product.is_subscription: + subscription_product = request.env[ + 'product.template'].sudo().browse(product.id) + subscription_plan = subscription_product.subscription_plan_id + recurrence_period = (subscription_product. + subscription_recurrence_period_ids) + values = { + 'search': search, + 'category': category, + 'pricelist': price_list, + 'attrib_values': attrib_values, + 'compute_currency': compute_currency, + 'attrib_set': attrib_set, + 'keep': keep, + 'categories': categories, + 'main_object': product, + 'product': product, + 'subscription_plan': subscription_plan, + 'recurrence_period': recurrence_period + } + return request.render("website_sale.product", values) + + @http.route(['/shop/cart/update_json'], type='json', auth="public", + methods=['POST'], website=True, csrf=False) + def cart_update_json(self, product_id, line_id=None, add_qty=None, + set_qty=None, display=True, **kw): + """ + This route is called : + - When changing quantity from the cart. + - When adding a product from the wishlist. + - When adding a product to cart on the same page + (without redirection). + """ + order = request.website.sale_get_order(force_create=1) + if order.state != 'draft': + request.website.sale_reset() + if kw.get('force_create'): + order = request.website.sale_get_order(force_create=1) + else: + return {} + + pcav = kw.get('product_custom_attribute_values') + nvav = kw.get('no_variant_attribute_values') + value = order._cart_update( + product_id=product_id, + line_id=line_id, + add_qty=add_qty, + set_qty=set_qty, + product_custom_attribute_values=json_scriptsafe.loads( + pcav) if pcav else None, + no_variant_attribute_values=json_scriptsafe.loads( + nvav) if nvav else None, + period=kw.get('period') + ) + + if not order.cart_quantity: + request.website.sale_reset() + return value + + order = request.website.sale_get_order() + value['cart_quantity'] = order.cart_quantity + + if not display: + return value + + value['website_sale.cart_lines'] = request.env[ + 'ir.ui.view']._render_template("website_sale.cart_lines", { + 'website_sale_order': order, + 'date': fields.Date.today(), + 'suggested_products': order._cart_accessories() + }) + value['website_sale.short_cart_summary'] = request.env[ + 'ir.ui.view']._render_template("website_sale.short_cart_summary", { + 'website_sale_order': order, + }) + return value diff --git a/website_subscription_package/data/mail_template_data.xml b/website_subscription_package/data/mail_template_data.xml new file mode 100755 index 000000000..d03c55ede --- /dev/null +++ b/website_subscription_package/data/mail_template_data.xml @@ -0,0 +1,56 @@ + + + + + Subscription: Send Subscription Order From Website + + {{ object.company_id.name }}: Subscription Order {{ object.name }} + {{ object.company_id.email }} + {{ object.partner_id.email }} + + + {{ object.partner_id.lang }} + +
+ + + + +
+ + + + + + + +
+ + + +
+
+ Dear Marc Demo, +
+
+ Your subscription + SUB001 + + has been created for product + Product + +
Do not Hesitate to contact us. +
+
+
+
+
+
+
+
diff --git a/website_subscription_package/doc/RELEASE_NOTES.md b/website_subscription_package/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..3fceb40c1 --- /dev/null +++ b/website_subscription_package/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 09.08.2024 +#### Version 15.0.1.0.0 +#### ADD +- Initial commit for Website Subscription Package Management diff --git a/website_subscription_package/models/__init__.py b/website_subscription_package/models/__init__.py new file mode 100644 index 000000000..710f8ed22 --- /dev/null +++ b/website_subscription_package/models/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import product_product +from . import product_template +from . import sale_order +from . import sale_order_line +from . import subscription_package diff --git a/website_subscription_package/models/product_product.py b/website_subscription_package/models/product_product.py new file mode 100644 index 000000000..832a6c5fb --- /dev/null +++ b/website_subscription_package/models/product_product.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import fields, models, _ + + +class ProductProduct(models.Model): + """Adding a new field for discounts for variants of subscription products + second subscription.""" + _inherit = "product.product" + + subscription_discount = fields.Float( + string="Discount(%)", help="Discount for second subscription.") + + def action_open_attribute_values_discount(self): + """Set Discounts for variants of subscription products second + subscription.""" + return { + 'type': 'ir.actions.act_window', + 'name': _("Product Variant Discount For 2nd subscription"), + 'res_model': 'product.product', + 'view_mode': 'tree', + 'views': [(self.env.ref('website_subscription_package.' + 'product_product_website_subscription_tree_view').id, 'list')], + 'context': { + 'search_default_product_tmpl_id': self.product_tmpl_id.id, + 'default_product_tmpl_id': self.product_tmpl_id.id}, + 'target': 'current'} diff --git a/website_subscription_package/models/product_template.py b/website_subscription_package/models/product_template.py new file mode 100644 index 000000000..73a0492bd --- /dev/null +++ b/website_subscription_package/models/product_template.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import fields, models, _ + + +class ProductTemplate(models.Model): + """Inherited product template model add new field to select recurrence + period for subscription product.""" + _inherit = "product.template" + + subscription_recurrence_period_ids = fields.Many2many( + comodel_name='recurrence.period', string='Recurrence period', + help="Select recurrence period (subscription interval) for the " + "product.") + + def action_open_attribute_values_discount(self): + """Set Discounts for variants of subscription products second + subscription.""" + + return { + 'type': 'ir.actions.act_window', + 'name': _("Product Variant Discount For 2nd subscription"), + 'res_model': 'product.product', + 'view_mode': 'tree', + 'views': [(self.env.ref('website_subscription_package.' + 'product_product_website_subscription_tree_view').id, + 'list')], + 'context': {'search_default_product_tmpl_id': self.id, + 'default_product_tmpl_id': self.id}, + 'target': 'new'} diff --git a/website_subscription_package/models/sale_order.py b/website_subscription_package/models/sale_order.py new file mode 100644 index 000000000..3943d36ea --- /dev/null +++ b/website_subscription_package/models/sale_order.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import models + + +class SaleOrder(models.Model): + """Extends the Sale Order model to handle subscription orders.""" + _inherit = 'sale.order' + + def _cart_update(self, product_id=None, line_id=None, add_qty=0, + set_qty=0, **kwargs): + """Supering the _cart_update function to write the interval_id""" + res = super()._cart_update(product_id=product_id, line_id=line_id, + add_qty=add_qty, set_qty=set_qty, **kwargs) + order_line = self.env['sale.order.line'].sudo().browse(res['line_id']) + if kwargs.get('period'): + order_line.write({ + 'subscription_interval_id': int(kwargs.get('period')), + }) + return res diff --git a/website_subscription_package/models/sale_order_line.py b/website_subscription_package/models/sale_order_line.py new file mode 100644 index 000000000..135219e64 --- /dev/null +++ b/website_subscription_package/models/sale_order_line.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import fields, models + + +class SaleOrderLine(models.Model): + """Add a new field to the sale order line for the subscription interval + for subscription product.""" + _inherit = 'sale.order.line' + + subscription_interval_id = fields.Many2one("recurrence.period", + string="Subscription Interval", + help="Recurrence period for " + "subscription product.") + is_product_subscription = fields.Boolean( + related='product_template_id.is_subscription', + string="Is Subscription", help="Is subscription product.") diff --git a/website_subscription_package/models/subscription_package.py b/website_subscription_package/models/subscription_package.py new file mode 100644 index 000000000..c7d2ac8b5 --- /dev/null +++ b/website_subscription_package/models/subscription_package.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sabeel B (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import fields, models + + +class SubscriptionPackage(models.Model): + """This class inherits from the 'subscription.package' model and extends + its functionality. It provides methods for sending subscription order + details to customers and managing subscription limits.""" + _inherit = "subscription.package" + + recurrence_period_id = fields.Many2one("recurrence.period", + string="Recurrence Period", + help="The period of the recurrence") + + def send_subscription_order_to_customer(self): + """Generates a mail and send to customer about the subscription order + details.""" + template_id = self.env.ref( + 'website_subscription_package.mail_template_subscription_order') + for rec in self: + email_vals = {'message_type': 'notification', + 'is_notification': True, + "model": 'subscription.package', + "res_id": rec.id} + template_id.send_mail( + rec.id, force_send=True, + notif_layout='mail.mail_notification_light', + email_values=email_vals) + + def close_limit_cron(self): + """It Checks renew date, close date. It will send mail when renew + date and also generates invoices based on the plan. + It wil close the subscription automatically if renewal limit is + exceeded.""" + pending_subscriptions = self.env['subscription.package'].search( + [('stage_category', '=', 'progress')]) + today_date = fields.Date.today() + pending_subscription = False + for pending_subscription in pending_subscriptions: + get_dates = self.find_renew_date( + pending_subscription.next_invoice_date, + pending_subscription.date_started, + pending_subscription.plan_id.days_to_end) + renew_date = get_dates['renew_date'] + end_date = get_dates['end_date'] + pending_subscription.close_date = get_dates['close_date'] + if today_date == pending_subscription.next_invoice_date: + if pending_subscription.plan_id.invoice_mode == 'draft_invoice': + this_products_line = [] + for rec in pending_subscription.product_line_ids: + rec_list = [0, 0, {'product_id': rec.product_id.id, + 'quantity': rec.product_qty, + 'price_unit': rec.unit_price, + 'discount': rec.product_id.subscription_discount, + 'tax_ids': rec.tax_id + }] + this_products_line.append(rec_list) + self.env['account.move'].create( + {'move_type': 'out_invoice', + 'invoice_date_due': today_date, + 'invoice_payment_term_id': False, + 'invoice_date': today_date, + 'state': 'draft', + 'subscription_id': pending_subscription.id, + 'partner_id': pending_subscription.partner_invoice_id.id, + 'currency_id': pending_subscription.partner_invoice_id.currency_id.id, + 'invoice_line_ids': this_products_line + }) + pending_subscription.write({ + 'to_renew': False, + 'start_date': pending_subscription.next_invoice_date}) + new_date = self.find_renew_date( + pending_subscription.next_invoice_date, + pending_subscription.date_started, + pending_subscription.plan_id.days_to_end) + pending_subscription.write( + {'close_date': new_date['close_date']}) + self.send_renew_alert_mail(today_date, + new_date['renew_date'], + pending_subscription.id) + if (today_date == end_date) and ( + pending_subscription.plan_id.limit_choice != 'manual'): + display_msg = ("
The renewal limit has been exceeded " + "today for this subscription based on the " + "current subscription plan.
") + pending_subscription.message_post(body=display_msg) + pending_subscription.is_closed = True + reason = (self.env['subscription.package.stop'].search([ + ('name', '=', 'Renewal Limit Exceeded')]).id) + pending_subscription.close_reason = reason + pending_subscription.closed_by = self.user_id + pending_subscription.close_date = fields.Date.today() + stage = (self.env['subscription.package.stage'].search([ + ('category', '=', 'closed')]).id) + values = {'stage_id': stage, 'to_renew': False, + 'next_invoice_date': False} + pending_subscription.write(values) + self.send_renew_alert_mail(today_date, renew_date, + pending_subscription.id) + return dict(pending=pending_subscription) diff --git a/website_subscription_package/security/ir.model.access.csv b/website_subscription_package/security/ir.model.access.csv new file mode 100644 index 000000000..0c6ad8d57 --- /dev/null +++ b/website_subscription_package/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_recurrence_period_user,access.recurrence.period.user,model_recurrence_period,base.group_user,1,1,1,1 diff --git a/website_subscription_package/static/description/assets/icons/check.png b/website_subscription_package/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/check.png differ diff --git a/website_subscription_package/static/description/assets/icons/chevron.png b/website_subscription_package/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/chevron.png differ diff --git a/website_subscription_package/static/description/assets/icons/cogs.png b/website_subscription_package/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/cogs.png differ diff --git a/website_subscription_package/static/description/assets/icons/consultation.png b/website_subscription_package/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/consultation.png differ diff --git a/website_subscription_package/static/description/assets/icons/ecom-black.png b/website_subscription_package/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/ecom-black.png differ diff --git a/website_subscription_package/static/description/assets/icons/education-black.png b/website_subscription_package/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/education-black.png differ diff --git a/website_subscription_package/static/description/assets/icons/hotel-black.png b/website_subscription_package/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/hotel-black.png differ diff --git a/website_subscription_package/static/description/assets/icons/license.png b/website_subscription_package/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/license.png differ diff --git a/website_subscription_package/static/description/assets/icons/lifebuoy.png b/website_subscription_package/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/lifebuoy.png differ diff --git a/website_subscription_package/static/description/assets/icons/logo.png b/website_subscription_package/static/description/assets/icons/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/logo.png differ diff --git a/website_subscription_package/static/description/assets/icons/manufacturing-black.png b/website_subscription_package/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/manufacturing-black.png differ diff --git a/website_subscription_package/static/description/assets/icons/pos-black.png b/website_subscription_package/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/pos-black.png differ diff --git a/website_subscription_package/static/description/assets/icons/puzzle.png b/website_subscription_package/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/puzzle.png differ diff --git a/website_subscription_package/static/description/assets/icons/restaurant-black.png b/website_subscription_package/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/restaurant-black.png differ diff --git a/website_subscription_package/static/description/assets/icons/service-black.png b/website_subscription_package/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/service-black.png differ diff --git a/website_subscription_package/static/description/assets/icons/trading-black.png b/website_subscription_package/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/trading-black.png differ diff --git a/website_subscription_package/static/description/assets/icons/training.png b/website_subscription_package/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/training.png differ diff --git a/website_subscription_package/static/description/assets/icons/update.png b/website_subscription_package/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/update.png differ diff --git a/website_subscription_package/static/description/assets/icons/user.png b/website_subscription_package/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/user.png differ diff --git a/website_subscription_package/static/description/assets/icons/wrench.png b/website_subscription_package/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/website_subscription_package/static/description/assets/icons/wrench.png differ diff --git a/website_subscription_package/static/description/assets/modules/automatic_image.png b/website_subscription_package/static/description/assets/modules/automatic_image.png new file mode 100644 index 000000000..a49c2a820 Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/automatic_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/budget_image.png b/website_subscription_package/static/description/assets/modules/budget_image.png new file mode 100644 index 000000000..b50130c7d Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/budget_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/crm_dashboard_image.png b/website_subscription_package/static/description/assets/modules/crm_dashboard_image.png new file mode 100644 index 000000000..6547c3081 Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/crm_dashboard_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/crm_image.png b/website_subscription_package/static/description/assets/modules/crm_image.png new file mode 100644 index 000000000..8793336c0 Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/crm_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/crm_kit_image.png b/website_subscription_package/static/description/assets/modules/crm_kit_image.png new file mode 100644 index 000000000..0bbad468d Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/crm_kit_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/employee_image.png b/website_subscription_package/static/description/assets/modules/employee_image.png new file mode 100644 index 000000000..30ad58232 Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/employee_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/ip_image.png b/website_subscription_package/static/description/assets/modules/ip_image.png new file mode 100644 index 000000000..707e2b7ed Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/ip_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/payable_image.png b/website_subscription_package/static/description/assets/modules/payable_image.png new file mode 100644 index 000000000..fd1059dec Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/payable_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/product_custom_image.png b/website_subscription_package/static/description/assets/modules/product_custom_image.png new file mode 100644 index 000000000..9c34fd89f Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/product_custom_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/salesperson_image.png b/website_subscription_package/static/description/assets/modules/salesperson_image.png new file mode 100644 index 000000000..958ed2bf4 Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/salesperson_image.png differ diff --git a/website_subscription_package/static/description/assets/modules/task_deadline_image.png b/website_subscription_package/static/description/assets/modules/task_deadline_image.png new file mode 100644 index 000000000..c128be58a Binary files /dev/null and b/website_subscription_package/static/description/assets/modules/task_deadline_image.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/hero.gif b/website_subscription_package/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..52d83a56a Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/hero.gif differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_001.png b/website_subscription_package/static/description/assets/screenshots/scrn_001.png new file mode 100644 index 000000000..b979680a5 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_001.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_0016.0.png b/website_subscription_package/static/description/assets/screenshots/scrn_0016.0.png new file mode 100644 index 000000000..3221dcdcd Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_0016.0.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_002.png b/website_subscription_package/static/description/assets/screenshots/scrn_002.png new file mode 100644 index 000000000..579dc642c Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_002.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_003.png b/website_subscription_package/static/description/assets/screenshots/scrn_003.png new file mode 100644 index 000000000..e4de6f463 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_003.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_004.png b/website_subscription_package/static/description/assets/screenshots/scrn_004.png new file mode 100644 index 000000000..e5e9de800 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_004.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_005.png b/website_subscription_package/static/description/assets/screenshots/scrn_005.png new file mode 100644 index 000000000..8a55454c7 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_005.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_006.png b/website_subscription_package/static/description/assets/screenshots/scrn_006.png new file mode 100644 index 000000000..dfb3cab33 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_006.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_007.png b/website_subscription_package/static/description/assets/screenshots/scrn_007.png new file mode 100644 index 000000000..42cf1a8e5 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_007.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_008.png b/website_subscription_package/static/description/assets/screenshots/scrn_008.png new file mode 100644 index 000000000..cb015f09c Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_008.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_009.png b/website_subscription_package/static/description/assets/screenshots/scrn_009.png new file mode 100644 index 000000000..9e68a4017 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_009.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_010.png b/website_subscription_package/static/description/assets/screenshots/scrn_010.png new file mode 100644 index 000000000..a2e1beb5a Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_010.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_011.png b/website_subscription_package/static/description/assets/screenshots/scrn_011.png new file mode 100644 index 000000000..1eaa9c6ec Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_011.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_012.png b/website_subscription_package/static/description/assets/screenshots/scrn_012.png new file mode 100644 index 000000000..2e4db87ce Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_012.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_013.png b/website_subscription_package/static/description/assets/screenshots/scrn_013.png new file mode 100644 index 000000000..734fcc70b Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_013.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_014.png b/website_subscription_package/static/description/assets/screenshots/scrn_014.png new file mode 100644 index 000000000..780ae4822 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_014.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_015.png b/website_subscription_package/static/description/assets/screenshots/scrn_015.png new file mode 100644 index 000000000..eca419a24 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_015.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_016.png b/website_subscription_package/static/description/assets/screenshots/scrn_016.png new file mode 100644 index 000000000..f6ef52e55 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_016.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_017.png b/website_subscription_package/static/description/assets/screenshots/scrn_017.png new file mode 100644 index 000000000..858558b9f Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_017.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_018.png b/website_subscription_package/static/description/assets/screenshots/scrn_018.png new file mode 100644 index 000000000..9ca534edf Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_018.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_019.png b/website_subscription_package/static/description/assets/screenshots/scrn_019.png new file mode 100644 index 000000000..6a58b40a0 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_019.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_020.png b/website_subscription_package/static/description/assets/screenshots/scrn_020.png new file mode 100644 index 000000000..3ff63780d Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_020.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_021.png b/website_subscription_package/static/description/assets/screenshots/scrn_021.png new file mode 100644 index 000000000..50484786c Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_021.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_022.png b/website_subscription_package/static/description/assets/screenshots/scrn_022.png new file mode 100644 index 000000000..9246cf2bd Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_022.png differ diff --git a/website_subscription_package/static/description/assets/screenshots/scrn_023.png b/website_subscription_package/static/description/assets/screenshots/scrn_023.png new file mode 100644 index 000000000..6012c5bd7 Binary files /dev/null and b/website_subscription_package/static/description/assets/screenshots/scrn_023.png differ diff --git a/website_subscription_package/static/description/banner.png b/website_subscription_package/static/description/banner.png new file mode 100644 index 000000000..9486f831a Binary files /dev/null and b/website_subscription_package/static/description/banner.png differ diff --git a/website_subscription_package/static/description/icon.png b/website_subscription_package/static/description/icon.png new file mode 100644 index 000000000..1064ed89e Binary files /dev/null and b/website_subscription_package/static/description/icon.png differ diff --git a/website_subscription_package/static/description/index.html b/website_subscription_package/static/description/index.html new file mode 100644 index 000000000..9a7794dfa --- /dev/null +++ b/website_subscription_package/static/description/index.html @@ -0,0 +1,698 @@ +
+
+
+
+ +
+
+
+ Community +
+ +
+
+
+
+ +
+
+
+

+ Website Subscription Package Management

+

+ This Module Create Subscription for A Product From + Website. +

+ +
+
+ + + + +
+
+

+ Overview +

+
+ +
+

+ + This Module Create Subscription for A Product + From + Website.

+ +
+
+ + +
+
+

+ Features +

+
+ +
+
+ +
+
+

+ Community compatible.

+
+
+
+
+ +
+
+

+ Auto Create Product Subscription and Sale Order From Website.

+
+
+ +
+
+ +
+
+

+ Send Mail After Auto Create Sale Order & Subscription To the customer.

+
+
+ +
+
+ +
+
+

+ Create Variant wise 2nd Subscription Discount.

+
+
+ +
+
+ +
+
+

+ User Can Manage Subscription from Portal.

+
+
+
+ +
+
+

+ Screenshots +

+
+
+

+ Create Recurrence Period And Subscription Plan.

+ + +
+ +
+

+ Go to Sales-> Configuration-> Settings. Enable 'Discounts'. +

+ +
+ +
+

+ Subscription Product.

+

+ Create New Subscription Product. +

+ +

+ Create Variants for the + Product. +

+ +

+ Enable 'Is Subscription' from 'Subscription' tab and + provide discount for variants.Select subscription plan and + Recurrence Period. +

+ +

+ Create variant wise Discount for Subscription Product. +

+ +
+ +
+

+ Select the Product from Website.

+ +

+ Select Recurrence Period and add to cart. +

+ +

+ Can see subscription details in Cart. +

+ +

+ Confirm the order. +

+ + +
+ +
+

+ Sale order and subscription order will be created.

+ + +

+ Send mail after auto create sale order & subscription to the + customer. +

+ +

+ Subscription Interval added in sale order line. +

+ +

+ Start the Subscription Order on clicking 'START' button. +

+ + +

+ Stage changed to IN PROGRESS. +

+ +
+ +
+

+ Customer can see their subscription order from Portal. +

+ + +
+ +
+

+ Click 'Start' to start the subscription Order from portal. +

+ + +
+ +
+

+ A recurring invoice will be generated for the subscription order according to the recurring period. Starting from the second invoice onward, variant-specific discount will be applied. +

+ +
+
+ + +
+
+

Suggested Products

+
+ + +
+
+ + + +
+
+
+

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+
+

Our Industries

+
+
+ +
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+ +
+
+ + + + + +
+
+
+

Need Help?

+
+
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
\ No newline at end of file diff --git a/website_subscription_package/static/src/js/website_sale.js b/website_subscription_package/static/src/js/website_sale.js new file mode 100644 index 000000000..ad0f71148 --- /dev/null +++ b/website_subscription_package/static/src/js/website_sale.js @@ -0,0 +1,30 @@ +/** @odoo-module **/ +import { WebsiteSale } from 'website_sale.website_sale'; +WebsiteSale.include({ + /** + * Assign the recurrence period to the rootProduct for subscription products. + * + * @override + */ + _submitForm: function () { + const params = this.rootProduct; + const $product = $('#product_detail'); + const recurrence = $('#recurrence_period')[0]; + let recurrence_id = 0; + const productTrackingInfo = $product.data('product-tracking-info'); + if (productTrackingInfo) { + productTrackingInfo.quantity = params.quantity; + $product.trigger('add_to_cart_event', [productTrackingInfo]); + } + for (let item of recurrence) { + if (item.selected === true) { + recurrence_id = item.value; + } + } + params.add_qty = params.quantity; + params.product_custom_attribute_values = JSON.stringify(params.product_custom_attribute_values); + params.no_variant_attribute_values = JSON.stringify(params.no_variant_attribute_values); + params['period'] = recurrence_id; + return this.addToCart(params); +}, +}); diff --git a/website_subscription_package/views/portal_templates.xml b/website_subscription_package/views/portal_templates.xml new file mode 100644 index 000000000..a26f0a217 --- /dev/null +++ b/website_subscription_package/views/portal_templates.xml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + diff --git a/website_subscription_package/views/product_product_views.xml b/website_subscription_package/views/product_product_views.xml new file mode 100644 index 000000000..d1bd911b7 --- /dev/null +++ b/website_subscription_package/views/product_product_views.xml @@ -0,0 +1,46 @@ + + + + + product.product.website.subscription.tree + product.product + + + + + + + + + + + + + + product.product.view.form.inherit.website.subscription.management + + product.product + + 25 + + + + + +