From 05640b7bc1062f0fca56447a84e9b8f8b12e3d47 Mon Sep 17 00:00:00 2001
From: Cybrosys Technologies
Date: Wed, 4 Dec 2024 17:18:36 +0530
Subject: [PATCH] Dec 04: [FIX] Bug Fixed 'website_product_uom_multi'
---
website_product_uom_multi/__manifest__.py | 2 +-
.../doc/RELEASE_NOTES.md | 6 +++++
.../models/sale_order.py | 25 +++++++++++--------
.../static/description/index.html | 12 +++++++++
4 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/website_product_uom_multi/__manifest__.py b/website_product_uom_multi/__manifest__.py
index 7eca92b11..b20b261a4 100644
--- a/website_product_uom_multi/__manifest__.py
+++ b/website_product_uom_multi/__manifest__.py
@@ -21,7 +21,7 @@
################################################################################
{
'name': 'Website Product Multi Uom',
- 'version': '17.0.1.0.0',
+ 'version': '17.0.1.0.1',
'category': 'Website',
'summary': 'Select the Products UOM before adding to Cart',
'description': 'This module allows customers to select the preferred '
diff --git a/website_product_uom_multi/doc/RELEASE_NOTES.md b/website_product_uom_multi/doc/RELEASE_NOTES.md
index d6bd5677d..4b786fd79 100644
--- a/website_product_uom_multi/doc/RELEASE_NOTES.md
+++ b/website_product_uom_multi/doc/RELEASE_NOTES.md
@@ -5,3 +5,9 @@
#### ADD
- Initial Commit for Website Product Multi Uom
+
+#### 04.12.2024
+#### Version 17.0.1.0.1
+#### BUGFIX
+
+- Fixed the uom issue on instant checkout
diff --git a/website_product_uom_multi/models/sale_order.py b/website_product_uom_multi/models/sale_order.py
index 74ae62857..2d0467097 100644
--- a/website_product_uom_multi/models/sale_order.py
+++ b/website_product_uom_multi/models/sale_order.py
@@ -43,7 +43,13 @@ class SaleOrder(models.Model):
_('It is forbidden to modify a sales order which is not in draft status.'))
product = self.env['product.product'].browse(product_id).exists()
- uom_id = self.env['uom.uom'].browse(uom)
+ uom_id = kwargs.pop('uom_id', None)
+ if uom is not None:
+ uom_id = uom
+
+ if uom_id:
+ uom_id = self.env['uom.uom'].browse(int(uom_id))
+
if add_qty and (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."))
@@ -51,15 +57,15 @@ class SaleOrder(models.Model):
if line_id is not False:
order_line = self._cart_find_product_line(product_id, line_id,
**kwargs)[:1]
- if uom_id :
+ if uom_id:
order_line_ids = order_line.order_id.order_line
- current_product_ids = order_line_ids.filtered(lambda l: l.product_id.id == product_id)
+ current_product_ids = order_line_ids.filtered(
+ lambda l: l.product_id.id == product_id)
if current_product_ids:
- order_line = current_product_ids.filtered(lambda n: n.product_uom.id == uom_id.id)
-
+ order_line = current_product_ids.filtered(
+ lambda n: n.product_uom.id == uom_id.id)
else:
order_line = self.env['sale.order.line']
-
try:
if add_qty:
add_qty = int(add_qty)
@@ -89,14 +95,13 @@ class SaleOrder(models.Model):
**kwargs,
)
else:
- # If the line will be removed anyway, there is no need to verify
- # the requested quantity update.
warning = ''
self._remove_delivery_line()
+ # Update order line
order_line = self._cart_update_order_line(product_id, quantity,
- order_line,uom_id, **kwargs)
+ order_line, uom_id, **kwargs)
if (
order_line
@@ -117,7 +122,6 @@ class SaleOrder(models.Model):
'warning': warning,
}
-
def _cart_update_order_line(self, product_id, quantity, order_line, uom_id, **kwargs):
"""
Update the order line in the cart based on the given product,
@@ -134,7 +138,6 @@ class SaleOrder(models.Model):
if update_values:
self._update_cart_line_values(order_line, update_values)
elif quantity > 0:
- # Create new line
order_line_values = self._prepare_order_line_values(product_id, quantity, **kwargs)
if uom_id:
order_line_values['product_uom'] = uom_id.id
diff --git a/website_product_uom_multi/static/description/index.html b/website_product_uom_multi/static/description/index.html
index 2095e718f..78abbdb41 100644
--- a/website_product_uom_multi/static/description/index.html
+++ b/website_product_uom_multi/static/description/index.html
@@ -234,6 +234,18 @@
style=" color:#718096!important; font-size:1rem !important;line-height: 28px;">
Initial Commit for Website Call For Price.
+
+
Version
+ 17.0.1.0.1|Released on:4th December 2024
+
+
+ Fixed the uom issue on instant checkout
+