diff --git a/website_decimal_quantity/README.rst b/website_decimal_quantity/README.rst new file mode 100644 index 000000000..e662b0f22 --- /dev/null +++ b/website_decimal_quantity/README.rst @@ -0,0 +1,47 @@ +.. 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 Decimal Quantity +======================== +This Module Allows Customers to Set Website-Shop Product Quantities in Decimal. + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +Affero General Public License v3.0 (AGPL v3) +(https://www.gnu.org/licenses/agpl-3.0-standalone.html ) + +Credits +------- +Developer: (v17) SANEEN K @ cybrosys +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_decimal_quantity/__init__.py b/website_decimal_quantity/__init__.py new file mode 100644 index 000000000..2e2623a8d --- /dev/null +++ b/website_decimal_quantity/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Saneen K @ cybrosys,(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_decimal_quantity/__manifest__.py b/website_decimal_quantity/__manifest__.py new file mode 100644 index 000000000..360cb9efe --- /dev/null +++ b/website_decimal_quantity/__manifest__.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Saneen K @ cybrosys,(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 Decimal Quantity', + 'version': '17.0.1.0.0', + 'category': 'Website', + 'summary': 'The app allows to select quantity in decimal for products ' + 'in Website/Shop', + 'description': """The app enables users to select quantities in decimal + values for products within the Website/Shop interface.""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['website_sale', 'website_sale_product_configurator'], + 'data': ['views/website_sale_product_configurator_templates.xml'], + 'assets': { + 'web.assets_frontend': [ + '/website_decimal_quantity/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_decimal_quantity/controllers/__init__.py b/website_decimal_quantity/controllers/__init__.py new file mode 100644 index 000000000..844fa9ef9 --- /dev/null +++ b/website_decimal_quantity/controllers/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Saneen K () +# +# 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 main +from . import website_sale_product_configurator diff --git a/website_decimal_quantity/controllers/main.py b/website_decimal_quantity/controllers/main.py new file mode 100644 index 000000000..54f23787c --- /dev/null +++ b/website_decimal_quantity/controllers/main.py @@ -0,0 +1,216 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Saneen K () +# +# 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 +from odoo import http +from odoo.http import request +from werkzeug.exceptions import NotFound +from odoo.tools.json import scriptsafe as json_scriptsafe +from odoo.addons.payment import utils as payment_utils +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteSaleDecimal(WebsiteSale): + """ + WebsiteSaleDecimal extends WebsiteSale class to update the methods: cart, + cart_update, cart_update_json and cart_quantity. + """ + + @http.route() + def cart(self, access_token=None, revive='', **post): + """ + Main cart management + abandoned cart revival + access_token: Abandoned cart SO access token + revive: Revival method when abandoned cart. Can be 'merge' or 'squash' + """ + order = request.website.sale_get_order() + if order and order.carrier_id: + # Express checkout is based on the amout of the sale order. If there is already a + # delivery line, Express Checkout form will display and compute the price of the + # delivery two times (One already computed in the total amount of the SO and one added + # in the form while selecting the delivery carrier) + order._remove_delivery_line() + if order and order.state != 'draft': + request.session['sale_order_id'] = None + order = request.website.sale_get_order() + + request.session['website_sale_cart_quantity'] = round( + sum(order.mapped('website_order_line.product_uom_qty')), 1) + + values = {} + if access_token: + abandoned_order = request.env['sale.order'].sudo().search( + [('access_token', '=', access_token)], limit=1) + if not abandoned_order: # wrong token (or SO has been deleted) + raise NotFound() + if abandoned_order.state != 'draft': # abandoned cart already finished + values.update({'abandoned_proceed': True}) + elif revive == 'squash' or ( + revive == 'merge' and not request.session.get( + 'sale_order_id')): # restore old cart or merge with unexistant + request.session['sale_order_id'] = abandoned_order.id + return request.redirect('/shop/cart') + elif revive == 'merge': + abandoned_order.order_line.write( + {'order_id': request.session['sale_order_id']}) + abandoned_order.action_cancel() + elif abandoned_order.id != request.session.get( + 'sale_order_id'): # abandoned cart found, user have to choose what to do + values.update({'access_token': abandoned_order.access_token}) + + values.update({ + 'website_sale_order': order, + 'date': fields.Date.today(), + 'suggested_products': [], + }) + if order: + order.order_line.filtered( + lambda l: not l.product_id.active).unlink() + values['suggested_products'] = order._cart_accessories() + values.update(self._get_express_shop_payment_values(order)) + + values.update(self._cart_values(**post)) + return request.render("website_sale.cart", values) + + @http.route() + def cart_update( + self, product_id, add_qty=1, set_qty=0, + product_custom_attribute_values=None, + no_variant_attribute_values=None, + express=False, **kwargs + ): + """This route is called when adding a product to cart (no options).""" + sale_order = request.website.sale_get_order(force_create=True) + if sale_order.state != 'draft': + request.session['sale_order_id'] = None + sale_order = request.website.sale_get_order(force_create=True) + + if product_custom_attribute_values: + product_custom_attribute_values = json_scriptsafe.loads( + product_custom_attribute_values) + + if no_variant_attribute_values: + no_variant_attribute_values = json_scriptsafe.loads( + no_variant_attribute_values) + + sale_order._cart_update( + product_id=int(product_id), + add_qty=add_qty, + set_qty=set_qty, + product_custom_attribute_values=product_custom_attribute_values, + no_variant_attribute_values=no_variant_attribute_values, + **kwargs + ) + + request.session[ + 'website_sale_cart_quantity'] = round( + sum(sale_order.mapped('website_order_line.product_uom_qty')), 1) + + if express: + return request.redirect("/shop/checkout?express=1") + return request.redirect("/shop/cart") + + @http.route() + def cart_update_json( + self, product_id, line_id=None, add_qty=None, set_qty=None, + display=True, + product_custom_attribute_values=None, + no_variant_attribute_values=None, **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=True) + if order.state != 'draft': + request.website.sale_reset() + if kw.get('force_create'): + order = request.website.sale_get_order(force_create=True) + else: + return {} + + if product_custom_attribute_values: + product_custom_attribute_values = json_scriptsafe.loads( + product_custom_attribute_values) + + if no_variant_attribute_values: + no_variant_attribute_values = json_scriptsafe.loads( + no_variant_attribute_values) + + values = order._cart_update( + product_id=product_id, + line_id=line_id, + add_qty=add_qty, + set_qty=set_qty, + product_custom_attribute_values=product_custom_attribute_values, + no_variant_attribute_values=no_variant_attribute_values, + **kw + ) + + values['notification_info'] = self._get_cart_notification_information( + order, [values['line_id']]) + values['notification_info']['warning'] = values.pop('warning', '') + request.session['website_sale_cart_quantity'] = round( + sum(order.mapped('website_order_line.product_uom_qty')), 1) + + if not order.cart_quantity: + request.website.sale_reset() + return values + + values['cart_quantity'] = round( + sum(order.mapped('website_order_line.product_uom_qty')), 1) + values['minor_amount'] = payment_utils.to_minor_currency_units( + order.amount_total, order.currency_id + ), + values['amount'] = order.amount_total + + if not display: + return values + + values['cart_ready'] = order._is_cart_ready() + values['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() + } + ) + values['website_sale.total'] = request.env[ + 'ir.ui.view']._render_template( + "website_sale.total", { + 'website_sale_order': order, + } + ) + return values + + @http.route() + def cart_quantity(self): + """ + This method updates the cart quantity count in the session based on + the order's website order lines. + """ + if 'website_sale_cart_quantity' not in request.session: + return request.website.sale_get_order().mapped( + 'website_order_line.product_uom_qty') + return request.session['website_sale_cart_quantity'] diff --git a/website_decimal_quantity/controllers/website_sale_product_configurator.py b/website_decimal_quantity/controllers/website_sale_product_configurator.py new file mode 100644 index 000000000..5fea8290e --- /dev/null +++ b/website_decimal_quantity/controllers/website_sale_product_configurator.py @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Saneen K () +# +# 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 . +# +############################################################################# +import json +from odoo import http +from odoo.http import request +from odoo.addons.website_sale_product_configurator.controllers.main import WebsiteSaleProductConfiguratorController + + +class WebsiteSaleDecimal(WebsiteSaleProductConfiguratorController): + """ + WebsiteSaleDecimal extends WebsiteSale class to update the + methods: cart_options_update_json. + """ + @http.route() + def cart_options_update_json(self, product_and_options, lang=None, + **kwargs): + """This route is called when submitting the optional product modal. + The product without parent is the main product, the other are options. + Options need to be linked to their parents with a unique ID. + The main product is the first product in the list and the options + need to be right after their parent. + product_and_options { + 'product_id', + 'product_template_id', + 'quantity', + 'parent_unique_id', + 'unique_id', + 'product_custom_attribute_values', + 'no_variant_attribute_values' + } + """ + if lang: + request.website = request.website.with_context(lang=lang) + + order = request.website.sale_get_order(force_create=True) + if order.state != 'draft': + request.session['sale_order_id'] = None + order = request.website.sale_get_order(force_create=True) + + product_and_options = json.loads(product_and_options) + if product_and_options: + # The main product is the first, optional products are the rest + main_product = product_and_options[0] + values = order._cart_update( + product_id=main_product['product_id'], + add_qty=main_product['quantity'], + product_custom_attribute_values=main_product[ + 'product_custom_attribute_values'], + no_variant_attribute_values=main_product[ + 'no_variant_attribute_values'], + **kwargs + ) + + line_ids = [values['line_id']] + + if values['line_id']: + # Link option with its parent iff line has been created. + option_parent = {main_product['unique_id']: values['line_id']} + for option in product_and_options[1:]: + parent_unique_id = option['parent_unique_id'] + option_values = order._cart_update( + product_id=option['product_id'], + set_qty=option['quantity'], + linked_line_id=option_parent[parent_unique_id], + product_custom_attribute_values=option[ + 'product_custom_attribute_values'], + no_variant_attribute_values=option[ + 'no_variant_attribute_values'], + **kwargs + ) + option_parent[option['unique_id']] = option_values[ + 'line_id'] + line_ids.append(option_values['line_id']) + + values[ + 'notification_info'] = self._get_cart_notification_information( + order, line_ids) + + values['cart_quantity'] = round( + sum(order.mapped('website_order_line.product_uom_qty')), 1) + request.session['website_sale_cart_quantity'] = round( + sum(order.mapped('website_order_line.product_uom_qty')), 1) + return values diff --git a/website_decimal_quantity/doc/RELEASE_NOTES.md b/website_decimal_quantity/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..671897d87 --- /dev/null +++ b/website_decimal_quantity/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 16.04.2024 +#### Version 17.0.1.0.0 +#### ADD +- Initial Commit for Website Decimal Quantity. diff --git a/website_decimal_quantity/models/__init__.py b/website_decimal_quantity/models/__init__.py new file mode 100644 index 000000000..c10e3052f --- /dev/null +++ b/website_decimal_quantity/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Saneen K () +# +# 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 sale_order diff --git a/website_decimal_quantity/models/sale_order.py b/website_decimal_quantity/models/sale_order.py new file mode 100644 index 000000000..1036d5a56 --- /dev/null +++ b/website_decimal_quantity/models/sale_order.py @@ -0,0 +1,124 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Saneen K () +# +# 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 api, models, _ +from odoo.exceptions import UserError +from odoo.http import request + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + """ + Inherit the 'sale.order' model to overwrite the _compute_cart_info + and _cart_update functions. + """ + @api.depends('order_line.product_uom_qty', 'order_line.product_id') + def _compute_cart_info(self): + """ + Making cart_quantity integer is avoided in order + to represent it in decimal values + """ + for order in self: + order.cart_quantity = sum(order.mapped + ('website_order_line.product_uom_qty')) + order.only_services = all( + line.product_id.type == 'service' for line in + order.website_order_line) + + def _cart_update(self, product_id, line_id=None, add_qty=0, set_qty=0, + **kwargs): + """ Add or set product quantity, add_qty can be negative. + + Making add_qty and set_qty integer are avoided in order + to represent them as decimal values. + """ + self.ensure_one() + if self.state != 'draft': + request.session.pop('sale_order_id', None) + request.session.pop('website_sale_cart_quantity', None) + raise UserError(_('It is forbidden to modify a sales order ' + 'which is not in draft status.')) + product = self.env['product.product'].browse(product_id).exists() + if not product or not product._is_add_to_cart_allowed(): + raise UserError(_("The given product does not exist " + "therefore it cannot be added to cart.")) + if product.lst_price == 0 and \ + product.website_id.prevent_zero_price_sale: + raise UserError(_("The given product does not have a price " + "therefore it cannot be added to cart.")) + if line_id is not False: + order_line = self._cart_find_product_line(product_id, + line_id, **kwargs)[:1] + else: + order_line = self.env['sale.order.line'] + try: + if add_qty: + pass + except ValueError: + add_qty = 1 + try: + if set_qty: + pass + except ValueError: + set_qty = 0 + quantity = 0 + if set_qty: + quantity = set_qty + elif add_qty is not None: + if order_line: + quantity = int(order_line.product_uom_qty) + int(add_qty or 0) + else: + quantity = add_qty or 0 + if float(quantity) > 0: + quantity, warning = self._verify_updated_quantity( + order_line, + product_id, + float(quantity), + **kwargs, + ) + + else: + # If the line will be removed anyway, there is no need to verify + # the requested quantity update. + warning = '' + if order_line and int(quantity) <= 0: + # Remove zero or negative lines + order_line.unlink() + order_line = self.env['sale.order.line'] + elif order_line: + # Update existing line + update_values = self._prepare_order_line_update_values( + order_line, quantity, **kwargs) + if update_values: + self._update_cart_line_values(order_line, update_values) + elif int(quantity) >= 0: + # Create new line + order_line_values = self._prepare_order_line_values( + product_id, quantity, **kwargs) + order_line = self.env['sale.order.line'].sudo().create( + order_line_values) + return { + 'line_id': order_line.id, + 'quantity': quantity, + 'option_ids': list(set(order_line.option_line_ids.filtered( + lambda l: l.order_id == order_line.order_id).ids)), + 'warning': warning, + } diff --git a/website_decimal_quantity/static/description/assets/icons/check.png b/website_decimal_quantity/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/check.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/chevron.png b/website_decimal_quantity/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/chevron.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/cogs.png b/website_decimal_quantity/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/cogs.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/consultation.png b/website_decimal_quantity/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/consultation.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/ecom-black.png b/website_decimal_quantity/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/ecom-black.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/education-black.png b/website_decimal_quantity/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/education-black.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/hotel-black.png b/website_decimal_quantity/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/hotel-black.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/license.png b/website_decimal_quantity/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/license.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/lifebuoy.png b/website_decimal_quantity/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/lifebuoy.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/manufacturing-black.png b/website_decimal_quantity/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/manufacturing-black.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/pos-black.png b/website_decimal_quantity/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/pos-black.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/puzzle.png b/website_decimal_quantity/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/puzzle.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/restaurant-black.png b/website_decimal_quantity/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/restaurant-black.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/service-black.png b/website_decimal_quantity/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/service-black.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/trading-black.png b/website_decimal_quantity/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/trading-black.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/training.png b/website_decimal_quantity/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/training.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/update.png b/website_decimal_quantity/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/update.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/user.png b/website_decimal_quantity/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/user.png differ diff --git a/website_decimal_quantity/static/description/assets/icons/wrench.png b/website_decimal_quantity/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/website_decimal_quantity/static/description/assets/icons/wrench.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/categories.png b/website_decimal_quantity/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/categories.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/check-box.png b/website_decimal_quantity/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/check-box.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/compass.png b/website_decimal_quantity/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/compass.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/corporate.png b/website_decimal_quantity/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/corporate.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/customer-support.png b/website_decimal_quantity/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/customer-support.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/cybrosys-logo.png b/website_decimal_quantity/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/cybrosys-logo.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/features.png b/website_decimal_quantity/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/features.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/logo.png b/website_decimal_quantity/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/logo.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/pictures.png b/website_decimal_quantity/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/pictures.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/pie-chart.png b/website_decimal_quantity/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/pie-chart.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/right-arrow.png b/website_decimal_quantity/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/right-arrow.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/star.png b/website_decimal_quantity/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/star.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/support.png b/website_decimal_quantity/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/support.png differ diff --git a/website_decimal_quantity/static/description/assets/misc/whatsapp.png b/website_decimal_quantity/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/misc/whatsapp.png differ diff --git a/website_decimal_quantity/static/description/assets/modules/2.png b/website_decimal_quantity/static/description/assets/modules/2.png new file mode 100644 index 000000000..511d4d392 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/2.png differ diff --git a/website_decimal_quantity/static/description/assets/modules/3.jpg b/website_decimal_quantity/static/description/assets/modules/3.jpg new file mode 100644 index 000000000..0415e22dd Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/3.jpg differ diff --git a/website_decimal_quantity/static/description/assets/modules/4.jpg b/website_decimal_quantity/static/description/assets/modules/4.jpg new file mode 100644 index 000000000..96245f77a Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/4.jpg differ diff --git a/website_decimal_quantity/static/description/assets/modules/5.jpg b/website_decimal_quantity/static/description/assets/modules/5.jpg new file mode 100644 index 000000000..a7a3264ef Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/5.jpg differ diff --git a/website_decimal_quantity/static/description/assets/modules/6.png b/website_decimal_quantity/static/description/assets/modules/6.png new file mode 100644 index 000000000..f3a24c620 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/6.png differ diff --git a/website_decimal_quantity/static/description/assets/modules/7.jpg b/website_decimal_quantity/static/description/assets/modules/7.jpg new file mode 100644 index 000000000..7995b26b9 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/7.jpg differ diff --git a/website_decimal_quantity/static/description/assets/screenshots/1.png b/website_decimal_quantity/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..286afcb69 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/screenshots/1.png differ diff --git a/website_decimal_quantity/static/description/assets/screenshots/2.png b/website_decimal_quantity/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..328244e0c Binary files /dev/null and b/website_decimal_quantity/static/description/assets/screenshots/2.png differ diff --git a/website_decimal_quantity/static/description/assets/screenshots/3.png b/website_decimal_quantity/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..302c8fcfd Binary files /dev/null and b/website_decimal_quantity/static/description/assets/screenshots/3.png differ diff --git a/website_decimal_quantity/static/description/assets/screenshots/hero.gif b/website_decimal_quantity/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..c7e5ad73c Binary files /dev/null and b/website_decimal_quantity/static/description/assets/screenshots/hero.gif differ diff --git a/website_decimal_quantity/static/description/banner.png b/website_decimal_quantity/static/description/banner.png new file mode 100644 index 000000000..a5dc70d2c Binary files /dev/null and b/website_decimal_quantity/static/description/banner.png differ diff --git a/website_decimal_quantity/static/description/icon.png b/website_decimal_quantity/static/description/icon.png new file mode 100644 index 000000000..f83907a1a Binary files /dev/null and b/website_decimal_quantity/static/description/icon.png differ diff --git a/website_decimal_quantity/static/description/index.html b/website_decimal_quantity/static/description/index.html new file mode 100644 index 000000000..022c0a362 --- /dev/null +++ b/website_decimal_quantity/static/description/index.html @@ -0,0 +1,659 @@ + + + + + + + Odoo App 3 Index + + + + + + + + +
+
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+
+
+
+

+ Website Decimal Quantity

+

In the Website/Shop Interface, Users have the + Capability to Specify Product Quantities Using Decimal + Values rather than being Limited to Whole Numbers. +

+
+ +
+
+
+
+
+

+ Key Highlights +

+
+
+
+
+
+ +
+
+

+ Allows to Select Quantity in Decimal for Products in Website.

+
+
+
+
+
+
+ +
+
+

+ Allows Users to Select Product in Decimal + Quantities from Product and Cart Page in Website/Shop.

+
+
+
+
+
+
+ +
+
+

+ Simultaneous Price Calculation in the Cart + According to the Selected Decimal Quantities.

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

+ Decimal Product Quantity in Product Page.

+
+
+
+
+
+
+ +
+
+

+ Decimal Product Quantity in Cart Page.

+
+
+
+
+
+
+ +
+
+

+ Simultaneous Price Calculation in Cart.

+
+
+
+
+
+
+
    +
  • + Allows to Select Quantity in Decimal for Products in Website. +
  • +
  • + Allows Users to Select Product in Decimal + Quantities from Product and Cart Page in Website/Shop. +
  • +
  • + Simultaneous Price Calculation in the Cart + According to the Selected Decimal Quantities. +
  • +
+
+
+
+
+
+
Version + 17.0.1.0.0|Released on:15th Apr 2024 +
+

+ Initial commit for Website Decimal Quantity

+
+
+
+
+
+
+
+

+ Related Products

+
+
+ +
+
+

+ Our Services

+ +
+
+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Customization

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Support

+
+
+
+
+
+
+ service-icon +
+
+

Hire + Odoo Developer

+
+
+
+
+ +
+
+ service-icon +
+
+

Odoo + Integration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Migration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Consultancy

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

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

+
+
+
+
+
+
+

+ Support

+
+
+
+
+
+
+
+ +
+ Need + Help? +

Got + questions or need help? Get in touch.

+
odoo@cybrosys.com +
+
+
+
+
+
+
+
+ +
+ WhatsApp +

Say hi to + us on WhatsApp!

+
+91 + 99456767686 +
+
+
+
+
+
+
+
+
+ + + + + + diff --git a/website_decimal_quantity/static/src/js/website_sale.js b/website_decimal_quantity/static/src/js/website_sale.js new file mode 100644 index 000000000..09daa94f0 --- /dev/null +++ b/website_decimal_quantity/static/src/js/website_sale.js @@ -0,0 +1,83 @@ +/** @odoo-module **/ + +import publicWidget from "@web/legacy/js/public/public_widget"; +import wSaleUtils from "@website_sale/js/website_sale_utils"; +import { Component } from "@odoo/owl"; + + +publicWidget.registry.WebsiteSale.include({ + /** +* This module extends the website_sale module to support decimal quantity input for adding products to the cart. +* It overrides the _onClickAddCartJSON function from sale.VariantMixin to add support for decimal quantity input, +* and extends the WebsiteSale widget to handle updating cart quantities when a decimal quantity is entered. +*/ + _onClickAddCartJSON(ev) { + ev.preventDefault(); + var $link = $(ev.currentTarget); + var $input = $link.closest('.input-group').find("input"); + var min = parseFloat($input.data("min") || 0); + var max = parseFloat($input.data("max") || Infinity); + var previousQty = parseFloat($input.val() || 0, 10); + var quantity = ($link.has(".fa-minus").length ? -0.1 : 0.1) + previousQty; + var newQt = quantity > min ? (quantity < max ? quantity : max) : min; + if (newQt !== previousQty) { + var newQty = newQt.toFixed(1); + $input.val(newQty).trigger('change'); + } + newQty = newQt.toFixed(1); + return false; + }, + /** Override the function _changeCartQuantity for changing the cart quantity **/ + _changeCartQuantity: function ($input, value, $dom_optional, line_id, productIDs) { + $($dom_optional).toArray().forEach((elem) => { + + $(elem).find('.js_quantity').text(value); + productIDs.push($(elem).find('span[data-product-id]').data('product-id')); + }); + $input.data('update_change', true); + + this.rpc("/shop/cart/update_json", { + line_id: line_id, + product_id: parseInt($input.data('product-id'), 10), + set_qty: value, + display: true, + }).then((data) => { + $input.data('update_change', false); + var check_value = parseFloat($input.val()); + if (isNaN(check_value)) { + check_value = 1; + } + if (value !== check_value) { + $input.trigger('change'); + return; + } + if (!data.cart_quantity) { + return window.location = '/shop/cart'; + } + $input.val(data.quantity); + $('.js_quantity[data-line-id='+line_id+']').val(data.quantity).text(data.quantity); + + wSaleUtils.updateCartNavBar(data); + wSaleUtils.showWarning(data.notification_info.warning); + // Propagating the change to the express checkout forms + Component.env.bus.trigger('cart_amount_changed', [data.amount, data.minor_amount]); + }); + }, +/** Override the function _onChangeCartQuantity **/ + _onChangeCartQuantity: function (ev) { + ev.preventDefault(); + var $input = $(ev.currentTarget); + if ($input.data('update_change')) { + return; + } + var value = parseFloat($input.val() || 0, 10); + if (isNaN(value)) { + value = 1; + } + var $dom = $input.closest('tr'); + var $dom_optional = $dom.nextUntil(':not(.optional_product.info)'); + var line_id = parseInt($input.data('line-id'), 10); + var productIDs = [parseInt($input.data('product-id'), 10)]; + this._changeCartQuantity($input, value, $dom_optional, line_id, productIDs); + }, +}); diff --git a/website_decimal_quantity/views/website_sale_product_configurator_templates.xml b/website_decimal_quantity/views/website_sale_product_configurator_templates.xml new file mode 100644 index 000000000..1c01066fd --- /dev/null +++ b/website_decimal_quantity/views/website_sale_product_configurator_templates.xml @@ -0,0 +1,28 @@ + + + + +