[FIX] website_sale, website_sale_stock: prevent out of stock
Steps to reproduce: - create a product; - disable the continue selling option for the out-of-stock; - do not have a stock quantity for this product. - go to ecommerce; - without click on the product, add it in the cart with the cart icon (on the picture). Issue: It is possible to add the product to the cart. If we repeat this several times, we will create quotations. Solution: Hide the button if the product is a storable product and we don't want to sell it if we have no stock. We also check the quantity available. opw-3148069 closes odoo/odoo#120176 X-original-commit: bf4b5962c396101f242822058b5ddf815408e3f8 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com> Signed-off-by: Lefebvre Thomas (thle) <thle@odoo.com>
This commit is contained in:
@@ -30,6 +30,9 @@ class ProductProduct(models.Model):
|
||||
combination_info = self.with_context(website_sale_stock_get_quantity=True).product_tmpl_id._get_combination_info(product_id=self.id)
|
||||
return combination_info['product_type'] == 'product' and combination_info['free_qty'] <= 0
|
||||
|
||||
def _website_show_quick_add(self):
|
||||
return (self.allow_out_of_stock_order or not self._is_sold_out()) and super()._website_show_quick_add()
|
||||
|
||||
def _send_availability_email(self):
|
||||
for product in self.search([('stock_notification_partner_ids', '!=', False)]):
|
||||
if product._is_sold_out():
|
||||
|
||||
@@ -59,3 +59,6 @@ class ProductTemplate(models.Model):
|
||||
|
||||
def _is_sold_out(self):
|
||||
return self.product_variant_id._is_sold_out()
|
||||
|
||||
def _website_show_quick_add(self):
|
||||
return (self.allow_out_of_stock_order or not self._is_sold_out()) and super()._website_show_quick_add()
|
||||
|
||||
Reference in New Issue
Block a user