Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

How to set global discount to fixed amount on POS

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
posdiscount
2 Antwoorden
3993 Weergaven
Avatar
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
Avatar
Annuleer
Avatar
Waleed Ali Mohsen
Beste antwoord

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
Avatar
Annuleer
Avatar
Nikolay B Petrov
Beste antwoord

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
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
POS Loyalty Promotion Reapplies Discount on Same Product — Cannot Reward Unique Lines
pos discount
Avatar
Avatar
1
mei 25
1752
Give discount according to the product count
pos discount
Avatar
Avatar
Avatar
2
okt. 16
3697
How to enter discount manually in POS?
pos discount
Avatar
Avatar
1
mrt. 15
5523
Buy 1 Get 1 Promotion in odoo 17.0 POS
pos discount buy1-get1
Avatar
Avatar
1
aug. 25
1688
Discount for first purchase at POS
pos discount Point Of Sale
Avatar
Avatar
1
jun. 25
1655
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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