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
    • Sociale 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

Code patch not taking effect. Inheriting the POS invoice_button component

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
pospoint_of_sale18.0l10n_mx
2 Antwoorden
1925 Weergaven
Avatar
Alvaro Brena

ODOO 18

I’m working on a POS module where I’m trying to apply a patch. The component is invoice_button. The issue is that when I run the POS to test it, the patch doesn’t take effect: if I add a console.log inside the onWillInvoiceOrder function, it doesn’t run. However, the console.log does run if I load it before the patch.


Could you guide me on what might be going wrong? I’m attaching some code and the module’s structure.

point_of_sale [invoice_button] -> l10n_mx_edi_pos [invoice_button] -> my_module [invoice_button]

All the other POS assets (JS included) are working as expected.

# Code

import { InvoiceButton } from "@point_of_sale/app/screens/ticket_screen/invoice_button/invoice_button";

import { AddInfoPopup } from "@l10n_mx_edi_pos/app/add_info_popup/add_info_popup";

import { makeAwaitable } from "@point_of_sale/app/store/make_awaitable_dialog";

import { patch } from "@web/core/utils/patch";


patch(InvoiceButton.prototype, {

async onWillInvoiceOrder(order, newPartner) {

if (this.pos.company.country_id?.code !== "MX") {

return true;

}

const payload = await makeAwaitable(this.dialog, AddInfoPopup, {

order,

newPartner,

});

if (payload) {

order.l10n_mx_edi_cfdi_to_public =

payload.l10n_mx_edi_cfdi_to_public === true ||

payload.l10n_mx_edi_cfdi_to_public === "1";

order.l10n_mx_edi_usage = payload.l10n_mx_edi_usage;

// Add new field for payment term

order.payment_term_id = payload.clientPaymentTerm || 0;

await this.pos.data.ormWrite("pos.order", [order.id], {

l10n_mx_edi_cfdi_to_public: order.l10n_mx_edi_cfdi_to_public,

l10n_mx_edi_usage: order.l10n_mx_edi_usage,

payment_term_id: order.payment_term_id,

});

}

return Boolean(payload);

},

});

# Manifest

"depends": [

"point_of_sale",

"pos_settle_due",

"l10n_mx_edi_pos",

],

"assets": {

"point_of_sale._assets_pos": [

"bck_pos_uso_cfdi/static/src/**/*",

],

},





0
Avatar
Annuleer
Avatar
D Enterprise
Beste antwoord

Hii,

/** @odoo-module **/


import { patch } from "@web/core/utils/patch";

import { registry } from "@web/core/registry";

import { InvoiceButton } from "@point_of_sale/app/screens/ticket_screen/invoice_button/invoice_button";

import { AddInfoPopup } from "@l10n_mx_edi_pos/app/add_info_popup/add_info_popup";

import { makeAwaitable } from "@point_of_sale/app/store/make_awaitable_dialog";


// Optional: Confirm patch is loaded

console.log("[bck_pos_uso_cfdi] Patching InvoiceButton...");


registry.category("pos_screens").add("patch_invoice_button", {

    async setup() {

        patch(InvoiceButton.prototype, {

            async onWillInvoiceOrder(order, newPartner) {

                console.log("[bck_pos_uso_cfdi] onWillInvoiceOrder triggered");


                if (this.pos.company.country_id?.code !== "MX") {

                    return true;

                }


                const payload = await makeAwaitable(this.dialog, AddInfoPopup, {

                    order,

                    newPartner,

                });


                if (payload) {

                    order.l10n_mx_edi_cfdi_to_public =

                        payload.l10n_mx_edi_cfdi_to_public === true ||

                        payload.l10n_mx_edi_cfdi_to_public === "1";

                    order.l10n_mx_edi_usage = payload.l10n_mx_edi_usage;

                    order.payment_term_id = payload.clientPaymentTerm || 0;


                    await this.pos.data.ormWrite("pos.order", [ order.id ], {

                        l10n_mx_edi_cfdi_to_public: order.l10n_mx_edi_cfdi_to_public,

                        l10n_mx_edi_usage: order.l10n_mx_edi_usage,

                        payment_term_id: order.payment_term_id,

                    });

                }


                return Boolean(payload);

            },

        });


        console.log("[bck_pos_uso_cfdi] Patch applied to InvoiceButton");

    },

});


I hope it is of full use.

1
Avatar
Annuleer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Beste antwoord

Hi,


You should patch the overridden InvoiceButton from l10n_mx_edi_pos, not the original @point_of_sale one.

1- Update the import.

import { InvoiceButton } from "@l10n_mx_edi_pos/app/screens/ticket_screen/invoice_button/invoice_button";

2- Then apply your patch as you did:

patch(InvoiceButton.prototype, {

  async onWillInvoiceOrder(order, newPartner) {

    console.log("Patched button clicked");  // Debug

    ...

  }

});


3- In your __manifest__.py, ensure your module is loaded after l10n_mx_edi_pos in the assets list:

"assets": {

    "point_of_sale._assets_pos": [

        "l10n_mx_edi_pos/static/src/**/*",  # already loaded before

        "bck_pos_uso_cfdi/static/src/**/*",  # your module after

    ],

},


This ensures your patch runs after all upstream overrides.


Hope it helps

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
Can I overwrite the “Order” button on the PoS?
pos point_of_sale owl 18.0
Avatar
Avatar
1
dec. 25
251
How to update point of sale order state?
pos point_of_sale
Avatar
Avatar
1
nov. 25
776
POS Custom Promotion Popup: Confirm button not triggering applyPromotions()
pos 18.0
Avatar
Avatar
1
okt. 25
1042
Odoo 18: Price tags in Point of Sale (POS) Opgelost
pos 18.0
Avatar
Avatar
Avatar
Avatar
Avatar
8
sep. 25
7448
How to print order bill and still have the possibility to make payment.
pos 18.0
Avatar
Avatar
Avatar
Avatar
Avatar
4
aug. 25
2973
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