[FIX] website_sale_stock: fix warning message if unavailable

Before this commit, the warning to inform the user that a product has
become unavailable was the same, whether the user was on the cart or on
the product page. This commit makes sure that the message is adapted to
the context.

closes odoo/odoo#139332

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
vava-odoo
2023-11-14 13:49:17 +00:00
parent bd07557b16
commit 8e69a3cc73
2 changed files with 19 additions and 3 deletions
@@ -189,6 +189,13 @@ msgstr ""
msgid "The following product is now available."
msgstr ""
#. module: website_sale_stock
#. odoo-python
#: code:addons/website_sale_stock/models/sale_order.py:0
#, python-format
msgid "The item has not been added to your cart since it is not available."
msgstr ""
#. module: website_sale_stock
#. odoo-python
#: code:addons/website_sale_stock/models/product_product.py:0
+12 -3
View File
@@ -41,12 +41,21 @@ class SaleOrder(models.Model):
order_line._set_shop_warning_stock(total_cart_qty, available_qty)
else:
self._set_shop_warning_stock(total_cart_qty, available_qty)
returned_warning = order_line.shop_warning or self.shop_warning
else: # 0 or negative allowed_qty
# if existing line: it will be deleted
# if no existing line: no line will be created
self.shop_warning = _(
"Some products became unavailable and your cart has been updated. We're sorry for the inconvenience.")
return allowed_line_qty, order_line.shop_warning or self.shop_warning
if order_line:
self.shop_warning = _(
"Some products became unavailable and your cart has been updated. We're"
" sorry for the inconvenience."
)
returned_warning = self.shop_warning
else:
returned_warning = _(
"The item has not been added to your cart since it is not available."
)
return allowed_line_qty, returned_warning
return super()._verify_updated_quantity(order_line, product_id, new_qty, **kwargs)
def _get_cart_and_free_qty(self, product, line=None):