I have some products that do not have any stock in my inventory. Instead of having the unavailable product or product variant displayed online (without an add to cart button which confuses customers), I want to keep it hidden. How can I do that?
I also notice that depending on the arrangement of your variants -- which you have no control -- if the first variants is out of stock, the add to cart button on your shop disappears. What can I do to improve my website in hiding product variants if they have no stock. When I try unchecking the active box and keep the product published, I get server errors. And, if I unpublish a variant, the whole product -- along with its available variants -- are also unpublished. I don't want to delete the variants because they will be useful reference for future purchases. What can be done?
This question has been flagged
Related Module: https://apps.odoo.com/apps/modules/18.0/website_hide_variants
1. https://www.odoo.com/sl_SI/forum/pomoc-1/hide-out-of-stock-variants-on-ecommerce-179359
Hope it helps.
By default, Odoo eCommerce keeps products visible even if they are out of stock, which can indeed confuse customers.
There are two clean ways to handle this without deleting variants.
✅ 1. Automatically Hide Products When Out of Stock
Enable stock-based visibility:
Go to Website → Configuration → Settings
Under Shop, enable:
Inventory Availability
Set Out-of-Stock behavior to:
“Show inventory below a threshold” or
Disable “Continue selling when out of stock”
Then on the product form:
Make sure Continue Selling is unchecked.
If a product has zero quantity and backorders are not allowed, Odoo will automatically remove the Add to Cart button and can prevent display depending on configuration.
✅ 2. Hide Out-of-Stock Variants (Recommended Approach)
The cleanest solution is to filter unavailable variants directly in the website template instead of archiving them.
Create a small custom module and inherit the product variant template to hide variants with zero stock.
Example override:
<template id="hide_out_of_stock_variants"
inherit_id="website_sale.product"
name="Hide Out of Stock Variants">
<xpath expr="//t[@t-foreach='combination_info.variant_values']"
position="attributes">
<attribute name="t-if">
combination_info.product_id.qty_available > 0
</attribute>
</xpath>
</template>
This ensures:
Variants with qty_available = 0 are not shown
The main product remains published
No server errors
Variants are preserved for future use
✅ 3. Fix “First Variant Out of Stock Removes Add to Cart”
This happens because Odoo selects the first variant by default.
To improve this behavior:
Reorder attribute values so an in-stock variant is first
OR
Customize the JS logic to automatically select the first available variant instead of the first defined one.
The proper technical solution is to adjust the combination selection logic in website_sale so that it selects a variant where qty_available > 0.
❌ What Not to Do
Do not uncheck Active on variants (causes integrity issues).
Do not unpublish variants individually (unpublishes entire template).
Do not delete variants if you need them later.
✔ Best Practice
If you want full control and clean UX:
Keep products published
Disable “Continue Selling”
Hide unavailable variants via template override
This keeps your catalog clean while preserving historical data.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
|
0
Feb 25
|
2312 | ||
|
|
1
Oct 23
|
4036 | ||
|
|
4
Oct 23
|
7547 | ||
|
|
1
Sep 22
|
2467 | ||
|
|
2
Apr 26
|
841 |