| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
Discuss (mail)
|
| Lines of code | 46 |
| Technical Name |
oyoor_pricelist_max_qty_rule |
| License | AGPL-3 |
| Website | https://www.linkedin.com/in/said-yahia-a3a64261 |
| Versions | 13.0 14.0 15.0 16.0 17.0 18.0 19.0 |
Price List with Max Qty Rule
Add an upper quantity boundary to any pricelist rule — so special pricing only applies when the sold quantity stays within your defined ceiling.
What does this module do?
Odoo's standard pricelist items allow a Min. Quantity threshold — but there is no built-in ceiling. This module adds a Max. Quantity field to every pricelist rule, giving you full range control over when a price applies.
The Core Problem
Standard Odoo pricelists trigger a rule for all quantities above the minimum. You cannot stop a promotional price from applying when a customer orders a very large quantity — which can erode margins unintentionally.
Bounded Pricing Rules
Set a Max. Quantity on any rule. If the ordered quantity exceeds that ceiling, Odoo automatically skips the rule and falls back to the next matching rule — or the product's list price.
Works in Sale & POS
The quantity check runs at the Odoo core pricing engine level, so it applies consistently in both Sales Orders and the Point of Sale module without extra configuration.
Pricing logic, step by step
The module hooks into Odoo's native _is_applicable_for method on product.pricelist.item.
Configure a Pricelist Rule
Open any pricelist and add or edit a rule. Two quantity fields now appear side by side: Min. Quantity (already existed) and the new Max. Quantity.
Set Your Ceiling
Enter a non-zero integer in Max. Quantity. A value of 0 means "no ceiling" — the rule behaves exactly as before the module was installed.
Odoo Evaluates the Rule
When a sale or POS line is computed, Odoo calls _is_applicable_for. The module intercepts: if max_quantity is set and the ordered quantity exceeds it, the rule returns False — it is skipped.
Fallback Pricing Applies
Odoo continues evaluating remaining pricelist rules in priority order. If none match, it falls back to the product's standard sales price — protecting your margins automatically.
Everything included
New Max. Quantity field on Pricelist Items
Visible in both the tree (list) and form views of pricelist rules — inserted cleanly right after Min. Quantity via XML inheritance.
Zero = No Ceiling (fully backward-compatible)
The default value is 0, which disables the upper-bound check. Existing pricelist rules behave identically after installation.
Applies to Sales Orders & Point of Sale
Implemented at the pricing engine level, not the UI layer — so the rule is enforced anywhere Odoo computes a price from a pricelist.
Community & Enterprise compatible
Depends only on base and product — no Enterprise-only dependencies. Installs on both editions without modification.
Lightweight — no new menus or models
A single model extension (product.pricelist.item) and three view patches. No migrations, no extra security rules, no configuration screens.
Core implementation
The entire business logic lives in a single Python method override on product.pricelist.item.
class PricelistItem(models.Model): _inherit = "product.pricelist.item" # New upper-bound field — default 0 means "no ceiling" max_quantity = fields.Integer('Max. Quantity', default=0) def _is_applicable_for(self, product, qty_in_product_uom): # Call original Odoo logic first res = super()._is_applicable_for(product, qty_in_product_uom) self.ensure_one() product.ensure_one() # If a ceiling is set and qty exceeds it → skip this rule if self.max_quantity and not qty_in_product_uom <= self.max_quantity: return False return res
Tech stack & compatibility:
Need help?
The author is available for support, customisation, and questions about this module.
Please log in to comment on this module