diff --git a/website_decimal_quantity/README.rst b/website_decimal_quantity/README.rst new file mode 100644 index 000000000..cc3874152 --- /dev/null +++ b/website_decimal_quantity/README.rst @@ -0,0 +1,46 @@ +.. 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 +------- +General Public License, Version 3 (AGPL v3). +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Credits +------- +* Developer: (V15) Fathima Mazlin AM, 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..85b09da6e --- /dev/null +++ b/website_decimal_quantity/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Fathima Mazlin AM @ 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 models diff --git a/website_decimal_quantity/__manifest__.py b/website_decimal_quantity/__manifest__.py new file mode 100644 index 000000000..c496f5c6b --- /dev/null +++ b/website_decimal_quantity/__manifest__.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Fathima Mazlin AM @ 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': '15.0.1.0.0', + 'category': 'eCommerce', + 'summary': 'The app allows to select quantity in decimal for products in ' + 'Website/Shop', + 'description': 'The app allows to select quantity in decimal for products' + 'in eCommerce.Product quantity is incremented by 0.1 while ' + 'clicking " + "button and decremented by 0.1 while ' + 'clicking " -" button in eCommerce', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['website_sale'], + 'data': ['views/website_sale_templates.xml'], + 'assets': { + 'web.assets_frontend': [ + '/website_decimal_quantity/static/src/js/variant_mixin.js', + '/website_decimal_quantity/static/src/js/website_sale.js', + ], + }, + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/website_decimal_quantity/doc/RELEASE_NOTES.md b/website_decimal_quantity/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..7db96b5a2 --- /dev/null +++ b/website_decimal_quantity/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 04.11.2023 +#### Version 15.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..9ea9304e6 --- /dev/null +++ b/website_decimal_quantity/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Fathima Mazlin AM @ 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 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..1907c557b --- /dev/null +++ b/website_decimal_quantity/models/sale_order.py @@ -0,0 +1,211 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Fathima Mazlin AM @ 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 . +# +############################################################################# +import logging +from odoo import api, fields, models, _ +from odoo.http import request +from odoo.exceptions import UserError, ValidationError +_logger = logging.getLogger(__name__) + + +class SaleOrder(models.Model): + """ Inherit the 'sale.order' model to overwrite the _compute_cart_info + and _cart_update functions.""" + _inherit = 'sale.order' + + cart_quantity = fields.Float(compute='_compute_cart_info', + string='Cart Quantity', help="Cart Quantity " + "in eCommerce") + + @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 = float(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() + product_context = dict(self.env.context) + product_context.setdefault('lang', self.sudo().partner_id.lang) + SaleOrderLineSudo = self.env['sale.order.line'].sudo().with_context( + product_context) + # Change lang to get correct name of attributes/values + product_with_context = self.env['product.product'].with_context( + product_context) + product = product_with_context.browse(int(product_id)).exists() + if not product or ( + not line_id and not product._is_add_to_cart_allowed()): + raise UserError( + _("The given product does not exist therefore it cannot " + "be added to cart.")) + try: + if add_qty: + add_qty = float(add_qty) + except ValueError: + add_qty = 1 + try: + if set_qty: + set_qty = float(set_qty) + except ValueError: + set_qty = 0 + quantity = 0 + order_line = False + if self.state != 'draft': + request.session['sale_order_id'] = None + raise UserError( + _('It is forbidden to modify a sales order which is not in ' + 'draft status.')) + if line_id is not False: + order_line = self._cart_find_product_line(product_id, line_id, + **kwargs)[:1] + # Create line if no line with product_id can be located + if not order_line: + no_variant_attribute_values = kwargs.get( + 'no_variant_attribute_values') or [] + received_no_variant_values = product.env[ + 'product.template.attribute.value'].browse( + [int(ptav['value']) for ptav in no_variant_attribute_values]) + received_combination = \ + product.product_template_attribute_value_ids\ + | received_no_variant_values + product_template = product.product_tmpl_id + # Handle all cases where incorrect or incomplete data are received + combination = product_template._get_closest_possible_combination( + received_combination) + # Get or create (if dynamic) the correct variant + product = product_template._create_product_variant(combination) + if not product: + raise UserError( + _("The given combination does not exist therefore it " + "cannot be added to cart.")) + product_id = product.id + values = self._website_product_id_change(self.id, product_id, + qty=1, **kwargs) + # Add no_variant attributes that were not received + for ptav in combination.filtered( + lambda ptav: + ptav.attribute_id.create_variant == + 'no_variant' and ptav not in received_no_variant_values): + no_variant_attribute_values.append({ + 'value': ptav.id, + }) + # Save no_variant attributes values + if no_variant_attribute_values: + values['product_no_variant_attribute_value_ids'] = [ + (6, 0, [int(attribute['value']) for attribute in + no_variant_attribute_values]) + ] + # Add is_custom attribute values that were not received + custom_values = kwargs.get('product_custom_attribute_values') or [] + received_custom_values = product.env[ + 'product.template.attribute.value'].browse( + [int(ptav['custom_product_template_attribute_value_id']) for + ptav in custom_values]) + for ptav in combination.filtered( + lambda ptav: + ptav.is_custom and ptav not in received_custom_values): + custom_values.append({ + 'custom_product_template_attribute_value_id': ptav.id, + 'custom_value': '', + }) + # Save is_custom attributes values + if custom_values: + values['product_custom_attribute_value_ids'] = [(0, 0, { + 'custom_product_template_attribute_value_id': custom_value[ + 'custom_product_template_attribute_value_id'], + 'custom_value': custom_value['custom_value'] + }) for custom_value in custom_values] + # Create the line + order_line = SaleOrderLineSudo.create(values) + try: + order_line._compute_tax_id() + except ValidationError as e: + # The validation may occur in backend (eg: taxcloud) + # but should fail silently in frontend + _logger.debug( + "ValidationError occurs during tax compute. %s" % (e)) + if add_qty: + add_qty -= 1 + # Compute new quantity + if set_qty: + quantity = set_qty + elif add_qty is not None: + quantity = order_line.product_uom_qty + (add_qty or 0) + # Remove zero of negative lines + if quantity <= 0: + linked_line = order_line.linked_line_id + order_line.unlink() + if linked_line: + # Update description of the parent + linked_product = product_with_context.browse( + linked_line.product_id.id) + linked_line.name = \ + linked_line.get_sale_order_line_multiline_description_sale( + linked_product) + else: + # Update line + no_variant_attributes_price_extra = [ + ptav.price_extra for ptav in order_line + .product_no_variant_attribute_value_ids] + values = self.with_context(no_variant_attributes_price_extra=tuple( + no_variant_attributes_price_extra))._website_product_id_change( + self.id, product_id, qty=quantity, **kwargs) + order = self.sudo().browse(self.id) + if self.pricelist_id.discount_policy == 'with_discount' \ + and not self.env.context.get('fixed_price'): + product_context.update({ + 'partner': order.partner_id, + 'quantity': quantity, + 'date': order.date_order, + 'pricelist': order.pricelist_id.id, + }) + product_with_context = self.env['product.product'].with_context( + product_context).with_company(order.company_id.id) + product = product_with_context.browse(product_id) + order_line.write(values) + # Link a product to the sales order + if kwargs.get('linked_line_id'): + linked_line = SaleOrderLineSudo.browse(kwargs['linked_' + 'line_id']) + order_line.write({ + 'linked_line_id': linked_line.id, + }) + linked_product = product_with_context.browse( + linked_line.product_id.id) + linked_line.name = \ + linked_line.get_sale_order_line_multiline_description_sale( + linked_product) + order_line.name = \ + order_line.get_sale_order_line_multiline_description_sale( + product) + option_lines = self.order_line.filtered( + lambda l: l.linked_line_id.id == order_line.id) + return {'line_id': order_line.id, 'quantity': quantity, + 'option_ids': list(set(option_lines.ids))} 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/delivery_date_ecommerce.png b/website_decimal_quantity/static/description/assets/modules/delivery_date_ecommerce.png new file mode 100644 index 000000000..5856d1b7e Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/delivery_date_ecommerce.png differ diff --git a/website_decimal_quantity/static/description/assets/modules/openai_website_product_media.png b/website_decimal_quantity/static/description/assets/modules/openai_website_product_media.png new file mode 100644 index 000000000..5c172b9ab Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/openai_website_product_media.png differ diff --git a/website_decimal_quantity/static/description/assets/modules/product_brand_ecommerce.png b/website_decimal_quantity/static/description/assets/modules/product_brand_ecommerce.png new file mode 100644 index 000000000..ae3e11bff Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/product_brand_ecommerce.png differ diff --git a/website_decimal_quantity/static/description/assets/modules/website_multi_variant.png b/website_decimal_quantity/static/description/assets/modules/website_multi_variant.png new file mode 100644 index 000000000..b64b96d92 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/website_multi_variant.png differ diff --git a/website_decimal_quantity/static/description/assets/modules/website_repeat_sale.png b/website_decimal_quantity/static/description/assets/modules/website_repeat_sale.png new file mode 100644 index 000000000..2b5926612 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/website_repeat_sale.png differ diff --git a/website_decimal_quantity/static/description/assets/modules/wishlist_product_website_backend.png b/website_decimal_quantity/static/description/assets/modules/wishlist_product_website_backend.png new file mode 100644 index 000000000..aa9cb6262 Binary files /dev/null and b/website_decimal_quantity/static/description/assets/modules/wishlist_product_website_backend.png 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..f42e1674d 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..05f5b1c63 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..6c3c92ad5 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..3a7296d01 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.jpg b/website_decimal_quantity/static/description/banner.jpg new file mode 100644 index 000000000..67101a2f4 Binary files /dev/null and b/website_decimal_quantity/static/description/banner.jpg 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..ae5580162 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..49acd7bc4 --- /dev/null +++ b/website_decimal_quantity/static/description/index.html @@ -0,0 +1,592 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ +
+
+
+ +

+ Website Decimal Quantity

+

+ Select Decimal Product Quantity from Website

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

Explore This + Module

+
+ + + + +
+
+ +
+

Overview +

+
+
+
+ This module allows users to choose products from the website shop in decimal quantities. This can be helpful + for users who need to select products in decimal quantities rather than multiples of one. +
+
+ + + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Decimal Product Quantity +
+
+ + Simultaneous Price Calculation +
+
+ + Accuracy +
+ +
+
+ + + +
+
+ +
+

Screenshots +

+
+
+
+ +
+

Decimal Product + Quantity in Product Page

+

Select product + quantities in decimal values from Product Page.

+ +
+ +
+

Decimal Product + Quantity in Cart Page

+

Select product + quantities in decimal values from Cart Page.

+ +
+ +
+

Simultaneous price + calculation in cart

+

Price is calculated in + the cart according to the decimal product values.

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

+ Related + 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

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

Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/website_decimal_quantity/static/src/js/variant_mixin.js b/website_decimal_quantity/static/src/js/variant_mixin.js new file mode 100644 index 000000000..6cff60cf9 --- /dev/null +++ b/website_decimal_quantity/static/src/js/variant_mixin.js @@ -0,0 +1,26 @@ +odoo.define('website_decimal_qty.VariantMixin', function (require) { +'use strict'; + + var VariantMixin = require('sale.VariantMixin'); + /** + * A custom implementation of the onClickAddCartJSON function in the + * sale.VariantMixin module. It allows for decimal quantities to be added to the cart + * by updating the input value with increments of 0.1. + */ + VariantMixin.onClickAddCartJSON = function (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; + } +}); 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..a2634ac16 --- /dev/null +++ b/website_decimal_quantity/static/src/js/website_sale.js @@ -0,0 +1,74 @@ +odoo.define('website_decimal_qty.website_sale', function (require) { +'use strict'; + + var publicWidget = require('web.public.widget'); + var wSaleUtils = require('website_sale.utils'); + const dom = require('web.dom'); + require('website_sale.website_sale'); + /** + * 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. + */ + publicWidget.registry.WebsiteSale.include({ + /**Override the function _changeCartQuantity to set decimal qty **/ + _changeCartQuantity: function ($input, value, $dom_optional, line_id, productIDs) { + _.each($dom_optional, function (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({ + route: "/shop/cart/update_json", + params: { + line_id: line_id, + product_id: parseInt($input.data('product-id'), 10), + set_qty: value + }, + }).then(function (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'; + } + wSaleUtils.updateCartNavBar(data); + $input.val(data.quantity); + $('.js_quantity[data-line-id='+line_id+']').val(data.quantity).text(data.quantity); + if (data.warning) { + var cart_alert = $('.oe_cart').parent().find('#data_warning'); + if (cart_alert.length === 0) { + $('.oe_cart').prepend(''); + } + else { + cart_alert.html(' ' + data.warning); + } + $input.val(data.quantity); + } + }); + }, + /**Override the function _onChangeCartQuantity to set decimal qty **/ + _onChangeCartQuantity: function (ev) { + 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_templates.xml b/website_decimal_quantity/views/website_sale_templates.xml new file mode 100644 index 000000000..49fd14f26 --- /dev/null +++ b/website_decimal_quantity/views/website_sale_templates.xml @@ -0,0 +1,25 @@ + + + + + + +