Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
productposrestrictionodoo17
1 Răspunde
3068 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Jainesh Shah(Aktiv Software)
Cel mai bun răspuns

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
Imagine profil
Abandonează
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);
},
});

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Error replacing header text in pos Rezolvat
pos odoo17
Imagine profil
Imagine profil
1
sept. 25
2240
Can Odoo create combo products with inventory deduction, variants, and add-ons?
product pos
Imagine profil
Imagine profil
1
ian. 25
2070
POS bill output v17
pos odoo17
Imagine profil
Imagine profil
1
aug. 24
2328
POS Proudct attribute popup, show attributes dynamically
pos odoo17
Imagine profil
0
iun. 24
1841
How can I sell configurable products (Pizza - REMOVE Onions or ADD Extra Cheese) in Odoo v9 POS?
product pos
Imagine profil
Imagine profil
2
aug. 16
4778
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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