Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

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

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
productposrestrictionodoo17
1 Odpowiedz
3062 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Jainesh Shah(Aktiv Software)
Najlepsza odpowiedź

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
Awatar
Odrzuć
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);
},
});

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Error replacing header text in pos Rozwiązane
pos odoo17
Awatar
Awatar
1
wrz 25
2240
Can Odoo create combo products with inventory deduction, variants, and add-ons?
product pos
Awatar
Awatar
1
sty 25
2066
POS bill output v17
pos odoo17
Awatar
Awatar
1
sie 24
2325
POS Proudct attribute popup, show attributes dynamically
pos odoo17
Awatar
0
cze 24
1841
How can I sell configurable products (Pizza - REMOVE Onions or ADD Extra Cheese) in Odoo v9 POS?
product pos
Awatar
Awatar
2
sie 16
4776
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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