| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Sales (sale_management)
• eCommerce (website_sale) • Discuss (mail) • Invoicing (account) • Website (website) |
| Lines of code | 299 |
| Technical Name |
website_min_max_qty_bytesfuel |
| License | LGPL-3 |
| Website | https://bytesfuel.com/ |
| Versions | 18.0 19.0 |
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Sales (sale_management)
• eCommerce (website_sale) • Discuss (mail) • Invoicing (account) • Website (website) |
| Lines of code | 299 |
| Technical Name |
website_min_max_qty_bytesfuel |
| License | LGPL-3 |
| Website | https://bytesfuel.com/ |
| Versions | 18.0 19.0 |
Website Minimum Quantity
Enforce minimum order quantities and purchase multiples for products — seamlessly across both the Odoo backend (Sale Orders) and the eCommerce website (Product page & Shopping Cart).
Take full control of order quantities
Prevent incorrect purchases — on every channel.
The Website Minimum Quantity module lets you define a Minimum Quantity (Min Qty) and a Maximum Quantity (Max Qty) directly on each product. Once set, the system enforces these limits end-to-end:
- Backend Sale Orders — real-time warnings & hard constraints stop invalid quantities from being saved.
- Website Product Page — the quantity input is pre-filled with the minimum, steps by the multiple, and shows an inline info badge.
- Website Shopping Cart — the
+/−buttons snap to the correct multiple; the server-side cart route also validates and auto-corrects quantities. - Add-to-Cart Gate — a JavaScript capture-phase listener blocks the add-to-cart action entirely if the quantity is invalid, showing a clear user-friendly notification.
Valid purchases: 10 · 20 · 30 · 40 …
Invalid purchases: 1 · 5 · 13 · 25 …
# Example: Max Qty = 100 on a product
Qty ≤ 100 → Allowed
Qty > 100 → Blocked / Auto-capped
Key Features
Everything you need to manage purchase quantity rules in one lightweight module.
Per-Product Quantity Fields
Two new fields added directly to the Product Template model: Min Qty (default 1) and Max Qty (0 = no limit). Configured from the product form under General Information → Quantity Limits.
Multiples Enforcement
Sales must be ordered in exact multiples of the minimum quantity.
If Min Qty = 5, only 5, 10, 15, 20 … are valid. The module checks via
qty % min_qty == 0 with a floating-point tolerance of ±0.001.
Maximum Quantity Cap
Optionally set a Max Qty to prevent customers or sales reps from ordering too much. Validated on both the website cart and the backend sale order. Setting Max Qty = 0 means no upper limit.
Smart Website Product Page
The quantity input on the product page is automatically set to
min_qty, steps by min_qty, and has HTML5 min/step/max
attributes applied via Qweb templates — no manual configuration required.
An info badge shows limits to the customer inline.
Cart Page Quantity Control
In the shopping cart, the + button increments by
min_qty and the − button decrements by the same step —
always snapping to the nearest valid multiple. The cart line input also has
data-min, data-step, and data-max attributes set.
Server-Side Cart Validation
The /shop/cart/update_json endpoint is overridden to auto-correct
quantities before they reach Odoo's cart logic — rounding to the nearest valid multiple
and capping at Max Qty. This prevents any invalid quantity from being saved even if JS is bypassed.
Real-Time User Notifications
The Odoo notification service displays a "Quantity Limit" warning toast whenever the user manually enters an invalid quantity on the website. The input is automatically reset to the nearest valid value.
Add-to-Cart Gating
A capture-phase JavaScript listener validates the quantity before
Odoo's own event handlers. If the quantity is invalid, preventDefault(),
stopPropagation(), and stopImmediatePropagation() are called —
completely blocking the add-to-cart action and showing a notification.
Backend Sale Order Enforcement
The Sale Order Line model has both an @api.onchange
(live popup warning in the UI) and an @api.constrains (hard DB-level check)
to ensure no invalid quantities are ever saved — even via RPC or imports.
See It In Action
Real examples of the module working on the backend and frontend.
1. Easy Admin Setup
Admins can easily set the minimum quantity multiple and maximum limit directly from the product template form. These limits are instantly synchronized across all sales channels.
2. Smart Web Store Integration
Customers see clear badges indicating the quantity limits right on the product page. The input field automatically steps in exact multiples (e.g., 5, 10, 15) when using the + and - buttons.
3. Live Frontend Warnings
If a user manually types an invalid number or bypasses the input steps, a clean popup warning alerts them immediately. The quantity is instantly auto-corrected before reaching the cart.
4. Strict Backend Protection
Sales representatives creating manual orders in the backend are also guided by strict constraints. Popups warn against invalid quantities, and the system prevents saving incorrect entries.
How It Works — Step-by-Step Workflow
From product configuration to enforced checkout.
Configuration (Admin)
Install the Module
Go to Apps → Search "Website Minimum Quantity" and click Install.
The module depends on sale_management and website_sale.
Open a Product Form
Navigate to Inventory / Sales → Products, open any product template, and go to the General Information tab.
Set Quantity Limits
In the Quantity Limits group, enter the desired
Minimum Quantity (e.g., 10) and optionally a
Maximum Quantity (e.g., 100, or leave 0 for unlimited).
Save the Product
Click Save. The limits are now active in all channels — backend and website — immediately.
Customer Experience (Website)
Browse the Product Page
The quantity input is pre-filled with min_qty. An info card below the
input displays: "Min Qty: 10 (multiples of 10)" and/or
"Max Qty: 100".
Use +/− Buttons
Clicking + increases the quantity by min_qty (e.g., 10 → 20 → 30).
Clicking − decreases by the same step. The value never drops below
min_qty or exceeds max_qty.
Manual Input Validation
If a customer types an invalid quantity (e.g., 13), a
"Quantity Limit" notification toast fires immediately, and the input
is auto-corrected to the nearest valid multiple (e.g., 10).
Add to Cart / Checkout
If the quantity is still invalid when the customer clicks Add to Cart,
the action is blocked entirely by the JS capture listener. The server further validates
and auto-corrects via the overridden /shop/cart/update_json endpoint.
Backend Sale Order Workflow
Add Product to Sale Order Line
When a sales rep adds a product in a Sale Order and enters a quantity,
the _onchange_qty_limits method fires immediately.
Live UI Warning
If the quantity is not a valid multiple or exceeds max_qty, a
yellow warning dialog appears inline in the form ("Invalid Quantity –
must be a multiple of X") without blocking navigation.
Hard Constraint on Save
The _check_qty_limits constraint runs when the order is confirmed or saved.
If the quantity is still invalid, a UserError is raised and the record
is not saved — protecting data integrity.
Order Confirmed with Valid Quantities
Once all line quantities comply with the configured rules, the sale order can be confirmed and processed normally through the standard Odoo workflow.
Help & Support
Need help configuring the module, extending its functionality, or integrating with custom workflows? Our team is here to help. You receive 90 days of free support after purchase (excludes data recovery, migration, or training).
Email: info@bytesfuel.com
Website: https://bytesfuel.com
Please log in to comment on this module