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 set global discount to fixed amount on POS

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
posdiscount
2 Odpowiedzi
3825 Widoki
Awatar
Fadil Kd

Hello,

I am working on Odoo 17e and I want to change the global discount to a fixed amount instead of percentage. How can I achieve that via custom module? Which functions should I target?

Any help is appreciated.

Thanks,

0
Awatar
Odrzuć
Awatar
Waleed Ali Mohsen
Najlepsza odpowiedź

Hi,

You need to change the js in the below file:

odoo/addons/pos_discount/static/src/overrides/components/discount_button/discount_button.js at 17.0 · odoo/odoo (github.com)

1
Awatar
Odrzuć
Awatar
Nikolay B Petrov
Najlepsza odpowiedź

Thank to @Waleen for pointing me in the right direction. The line to edit in that file is #27. This is only if you want to change the discount to apply as a fixed amount.

Here's a modification of the same file that first gives you a selection popup to choose whether you want a fixed or % discount, then you enter the discount amount

(sorry, code formatting is not applying properly so you'll have to copy-paste in your IDE and format)


/** @odoo-module **/

import { _t } from "@web/core/l10n/translation";import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";import { useService } from "@web/core/utils/hooks";import { NumberPopup } from "@point_of_sale/app/utils/input_popups/number_popup";import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup"; // Assuming SelectionPopup exists or create a similar componentimport { Component } from "@odoo/owl";import { usePos } from "@point_of_sale/app/store/pos_hook";import { parseFloat } from "@web/views/fields/parsers";

export class DiscountButton extends Component {    static template = "pos_discount.DiscountButton";

    setup() {        this.pos = usePos();        this.popup = useService("popup");    }

    async click() {        // First, ask the user to choose discount type        const { confirmed: typeConfirmed, payload: discountType } = await this.popup.add(SelectionPopup, {            title: _t("Discount Type"),            list: [                { id: 1, label: _t("Percentage"), item: "percentage", isSelected: true },                { id: 2, label: _t("Fixed Amount"), item: "fixed" },            ],            isInputSelected: true,        });        if (!typeConfirmed) return;

        // Ask for discount value based on the chosen type        const { confirmed, payload } = await this.popup.add(NumberPopup, {            title: discountType === "percentage" ? _t("Discount Percentage") : _t("Discount Amount"),            startingValue: this.pos.config.discount_pc || 0,            isInputSelected: true,        });        if (confirmed) {            const val = parseFloat(payload);            await this.apply_discount(val, discountType);        }    }

    async apply_discount(value, discountType) {        const order = this.pos.get_order();        const lines = order.get_orderlines();        const product = this.pos.db.get_product_by_id(this.pos.config.discount_product_id[0]);

        if (product === undefined) {            await this.popup.add(ErrorPopup, {                title: _t("No discount product found"),                body: _t(                    "The discount product seems misconfigured. Make sure it is flagged as 'Can be Sold' and 'Available in Point of Sale'."                ),            });            return;        }

        // Remove existing discounts        lines            .filter((line) => line.get_product() === product)            .forEach((line) => order._unlinkOrderline(line));

        // Add one discount line per tax group        const linesByTax = order.get_orderlines_grouped_by_tax_ids();        for (const [tax_ids, lines] of Object.entries(linesByTax)) {            const tax_ids_array = tax_ids                .split(",")                .filter((id) => id !== "")                .map((id) => Number(id));

            const baseToDiscount = order.calculate_base_amount(                tax_ids_array,                lines.filter((ll) => ll.isGlobalDiscountApplicable())            );

            // Calculate discount based on type            let discount = 0;            if (discountType === "percentage") {                discount = (-value / 100.0) * baseToDiscount;            } else if (discountType === "fixed") {                discount = -value;            }

            if (discount < 0) {                order.add_product(product, {                    price: discount,                    lst_price: discount,                    tax_ids: tax_ids_array,                    merge: false,                    description:                        `${discountType === "percentage" ? value + "%" : this.pos.currency.symbol + value}, ` +                        (tax_ids_array.length                            ? _t(                                  "Tax: %s",                                  tax_ids_array                                      .map((taxId) => this.pos.taxes_by_id[taxId].amount + "%")                                      .join(", ")                              )                            : _t("No tax")),                    extras: {                        price_type: "automatic",                    },                });            }        }    }}

ProductScreen.addControlButton({    component: DiscountButton,    condition: function () {        const { module_pos_discount, discount_product_id } = this.pos.config;        return module_pos_discount && discount_product_id;    },});


1
Awatar
Odrzuć
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ść
POS Loyalty Promotion Reapplies Discount on Same Product — Cannot Reward Unique Lines
pos discount
Awatar
Awatar
1
maj 25
1668
Give discount according to the product count
pos discount
Awatar
Awatar
Awatar
2
paź 16
3637
How to enter discount manually in POS?
pos discount
Awatar
Awatar
1
mar 15
5444
Buy 1 Get 1 Promotion in odoo 17.0 POS
pos discount buy1-get1
Awatar
Awatar
1
sie 25
1586
Discount for first purchase at POS
pos discount Point Of Sale
Awatar
Awatar
1
cze 25
1577
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