In Stock / Out of Stock badge on product cards
Display an In Stock / Out of Stock badge on every product card in your Odoo online shop — automatically.
Overview
Stock Badge Website adds a visible availability badge to every product card on your eCommerce storefront. Customers can immediately know whether a product is available without opening the product page, reducing unnecessary clicks and improving the shopping experience.
The badge is computed using Odoo's native Forecasted Quantity
(virtual_available) field on the product template. This means the badge
does not only reflect the current on-hand stock — it also takes into
account all confirmed incoming and outgoing stock moves (pending receipts, deliveries,
manufacturing orders, etc.).
⚠ Important — Forecasted Quantity, not On-Hand
The badge uses virtual_available (Forecasted Qty), not
qty_available (On-Hand Qty).
- A product with 0 units on hand but a confirmed incoming receipt of 10 units will show In Stock, because its forecasted quantity is +10.
- A product with 5 units on hand but a confirmed outgoing delivery of 5 units will show Out of Stock, because its forecasted quantity is 0.
-
The threshold is strictly greater than zero:
virtual_available > 0→ In Stock, otherwise → Out of Stock. - Practical case: a product with 3 units on hand but all 3 reserved for a confirmed customer delivery has a Forecasted Qty of 0 → displayed as Out of Stock on the website, even though physical stock exists in the warehouse.
Badge Logic Explained
✓ In Stock (green badge)
Displayed when: virtual_available > 0
virtual_available includes:
- Current on-hand quantity
- + Confirmed incoming receipts (Purchase Orders)
- + Confirmed incoming manufacturing orders
- − Confirmed outgoing deliveries (Sale Orders)
- − Confirmed outgoing manufacturing components
✗ Out of Stock (red badge)
Displayed when: virtual_available <= 0
Typical cases:
- On-hand stock is zero with no pending receipts
- All on-hand units are reserved by confirmed deliveries
- Forecasted quantity is negative (backorder situation)
Quick Reference — Badge vs. Stock Scenario
| On-Hand Qty | Incoming (confirmed) | Outgoing (confirmed) | Forecasted Qty | Badge shown |
|---|---|---|---|---|
| 10 | 0 | 0 | 10 | ✓ In Stock |
| 0 | 5 | 0 | 5 | ✓ In Stock |
| 10 | 0 | 10 | 0 | ✗ Out of Stock |
| 0 | 0 | 0 | 0 | ✗ Out of Stock |
| 3 | 0 | 5 | −2 | ✗ Out of Stock |
📷 Real-World Example — Tested on Odoo 17
Consider two products in your shop:
| Product | On-Hand Qty | Reserved (confirmed delivery) | Forecasted Qty | Badge on website |
|---|---|---|---|---|
| PEAK SHOES | 5 | 0 | 5 | ✓ IN STOCK |
| PEAK SHOES ROSY | 3 | 3 (reserved to a customer) | 0 | ✗ OUT OF STOCK |
PEAK SHOES ROSY has 3 units on hand, but all 3 are reserved for a confirmed customer delivery. Its Forecasted Qty = 0, so the website correctly displays Out of Stock — preventing new customers from ordering a product that is already fully committed.
Key Features
🔄 Forecasted Qty Based
Uses virtual_available — reflects confirmed receipts
and deliveries, not just physical on-hand stock.
🎨 Clean Design
Pill-shaped badges with uppercase text and icon — integrates naturally with any Odoo eCommerce theme.
⚙ Zero Configuration
Install and go. Badges appear automatically on all product cards — no settings required.
🔗 Lightweight
One CSS file, one QWeb template override. No JavaScript, no external dependencies.
🕙 Placed Above Price
Badge is injected just before the price block — visible at a glance without scrolling or opening the product page.
🔓 Safe Read
Stock is read with sudo() to ensure the badge
is visible to all website visitors regardless of their access rights.
Installation
-
Copy the
stock_badge_websitefolder into your Odoo addons directory. - Update the apps list: Apps → Update Apps List.
- Search for Stock Badge Website and click Install.
- Visit your online shop — badges appear automatically on every product card.
Requirement: the Website Sale (eCommerce) app must be installed.
Technical Notes
- Odoo version: 17.0
- Dependency:
website_sale -
Stock field:
product.template.virtual_available— Forecasted Quantity (on-hand + incoming − outgoing, confirmed moves only) - Threshold:
virtual_available > 0→ In Stock - Template overridden:
website_sale.products_item - License: LGPL-3 (free & open source)
Please log in to comment on this module
There are no ratings yet!