Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Code patch not taking effect. Inheriting the POS invoice_button component

Subscribe

Get notified when there's activity on this post

This question has been flagged
pospoint_of_sale18.0l10n_mx
2 Replies
1888 Views
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
Discard
Avatar
D Enterprise
Best Answer

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
Discard
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

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
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Can I overwrite the “Order” button on the PoS?
pos point_of_sale owl 18.0
Avatar
Avatar
1
Dec 25
146
How to update point of sale order state?
pos point_of_sale
Avatar
Avatar
1
Nov 25
739
POS Custom Promotion Popup: Confirm button not triggering applyPromotions()
pos 18.0
Avatar
Avatar
1
Oct 25
1023
Odoo 18: Price tags in Point of Sale (POS) Solved
pos 18.0
Avatar
Avatar
Avatar
Avatar
Avatar
8
Sep 25
7405
How to print order bill and still have the possibility to make payment.
pos 18.0
Avatar
Avatar
Avatar
Avatar
Avatar
4
Aug 25
2952
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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