Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How to Implement Maximum Purchase Quantity Limit Per Product in POS Order - Odoo 17

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
productposrestrictionodoo17
1 Répondre
3069 Vues
Avatar
Tenth Planet

Environment: Odoo Version: 17.0 (Enterprise/Community)- Module: Point of Sale

Business Requirement:

We need to implement a maximum quantity limit per product in POS orders to prevent bulk purchases during promotional periods. 

Specific Requirements:

1. Configure maximum allowed quantity per product

2. Display warning/restriction in POS when quantity exceeds the limit

3. Prevent order completion OR show alert message when limit is exceeded

Use Case:

During promotional offers, we need to ensure fair distribution of discounted products to end consumers by preventing bulk purchases. For example:- Product A has a max limit of 5 units per order- If customer tries to purchase 7 units, system should either:  - Show warning message  - OR prevent adding more than 5 units  - OR require manager approval for exceeding limit

Questions:

1. Is there any existing functionality in Odoo 17 to achieve this?

2. If not, what would be the recommended approach to implement this?   

​2a. Custom field for max quantity limit on product form?   

​2b. POS order line validation?   

​2c. Alert/restriction mechanism?

What we've Investigated: Checked standard POS configuration options- Reviewed product form fields- Searched for similar implementations

Any guidance on implementing this feature would be greatly appreciated. Technical implementation details or pointers to similar solutions would be helpful.


Regards
odoo@tenthplanet

0
Avatar
Ignorer
Avatar
Jainesh Shah(Aktiv Software)
Meilleure réponse

Hello, Tenth Planet,


To implement a maximum purchase quantity limit per product in a POS order, follow the steps outlined below:


1. Add a New Field in the Product Model


File: `models/product_product.py`

Objective: Add a new field to the `product.product` model to store the quantity limit for each product.


//Code 1 in comment//


2. Inherit the POS Data Loader in POS Session Model


File: `models/pos_session.py`

Objective: Ensure the `pos_product_qty_limit` field is loaded into the POS session for use in the frontend.


//Code 2 in comment//


3. Patch the POS Order Model


File: `static/src/js/models/order.js`

Objective: Add a validation step in the `pay` method to enforce the product quantity limit during payment.


Add this file path in the manifest under `"point_of_sale.assets_prod"`.


//Code 3 in Comment//


Ensure the `point_of_sale` dependency is added to the `__manifest__.py` file. Additionally, include the new JavaScript file path in `"point_of_sale.assets_prod"`.


5. Payment Button Behavior


When a user clicks the "Payment" button in the POS screen: 

- If a product's quantity exceeds the limit, an error popup is displayed. 

- Payment is blocked until the product quantities are corrected.


6. Output


Below is an example of the error popup displayed when a product's quantity exceeds its limit. 


 


Hope this helps! If you need any assistance with customization, feel free to contact us.


Thanks & Regards,

Email:  odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari


0
Avatar
Ignorer
Jainesh Shah(Aktiv Software)

//Code 1//

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _

class ProductProduct(models.Model):
_inherit = "product.product"

# New field to define the maximum quantity limit for a product in POS.
pos_product_qty_limit = fields.Integer("POS Product Quantity Limit")

//Code 2//

# -*- coding: utf-8 -*-
from odoo import models

class PosSession(models.Model):
_inherit = "pos.session"

def _loader_params_product_product(self):
"""
This method customizes the loader parameters for loading product data in a POS session.
Specifically, it ensures that the `pos_product_qty_limit` field is included
when product data is loaded into the POS interface.
"""
result = super()._loader_params_product_product()

# Add the `pos_product_qty_limit` field to the list of fields to be loaded.
result["search_params"]["fields"].extend(["pos_product_qty_limit"])

return result

//Code 3//

/* @odoo-module */

import { patch } from "@web/core/utils/patch";
import { Order } from "@point_of_sale/app/store/models";
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
import { _t } from "@web/core/l10n/translation";

// Patch the Order model to include quantity validation during payment.
patch(Order.prototype, {
/**
* Override the `pay` method to include custom validation logic for product quantity limits.
* This ensures that users cannot pay for an order if any product's quantity exceeds its defined limit.
*/
async pay() {
const orderLines = this.get_orderlines();

for (const line of orderLines) {
const posProductQtyLimit = line.product.pos_product_qty_limit;
// Check if the quantity exceeds the limit.
if (posProductQtyLimit > 0 && line.quantity > posProductQtyLimit) {
// Display a warning popup if the limit is exceeded.
this.env.services.popup.add(ErrorPopup, {
title: _t("Product Quantity Exceeded"),
body: _t(`The quantity for the product "${line.product.display_name}" exceeds the limit. You cannot add a quantity greater than "${posProductQtyLimit}".`),
});
return;
}
}
return super.pay(...arguments);
},
});

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Error replacing header text in pos Résolu
pos odoo17
Avatar
Avatar
1
sept. 25
2240
Can Odoo create combo products with inventory deduction, variants, and add-ons?
product pos
Avatar
Avatar
1
janv. 25
2070
POS bill output v17
pos odoo17
Avatar
Avatar
1
août 24
2328
POS Proudct attribute popup, show attributes dynamically
pos odoo17
Avatar
0
juin 24
1841
How can I sell configurable products (Pizza - REMOVE Onions or ADD Extra Cheese) in Odoo v9 POS?
product pos
Avatar
Avatar
2
août 16
4778
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now