[FIX] website_sale: add product with extra price to cart

Version: 16.0

Prerequisites:
- "Pricelist" enabled
- "Prevent Sale of Zero Priced Product" enabled

Steps:
- Create a product:
	- Sales Price: 0
	- In the  "Sales" tab set "website" to a website
	- Add Extra Prices (smart button)
		- Public Pricelist (USD)
		- Min. Quantity: 0
		- Price: 100
- Go to the shop, choose the correct pricelist and try to add the product to the cart

Issue:
UserError:  The given product does not have a price therefore it cannot be added to cart.

Cause:
It doesn't compare the good price list considering the context

opw-3339524

closes odoo/odoo#124898

X-original-commit: facd44d0bd4352be3d0eb11a2675e7a518c97e59
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Eteil Djoumatchoua(etdj)
2023-06-15 17:36:41 +02:00
parent 722d00ff91
commit 8d0625a95f
+5 -3
View File
@@ -166,9 +166,6 @@ class SaleOrder(models.Model):
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."))
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:
@@ -211,6 +208,11 @@ class SaleOrder(models.Model):
order_line = self._cart_update_order_line(product_id, quantity, order_line, **kwargs)
if order_line and order_line.price_unit == 0 and self.website_id.prevent_zero_price_sale:
raise UserError(_(
"The given product does not have a price therefore it cannot be added to cart.",
))
return {
'line_id': order_line.id,
'quantity': quantity,