Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

print purview came empty when I use windows.print()

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
javascriptodoo16
1 Atsakyti
2106 Rodiniai
Portretas
ahmed mohamady

I try to add button in POS screen to print a simple HTML code 
And I use this code for this, 

        async _printWeb(receipt) {

            try {

                const receiptContainer = $(this.el).find('.pos-cash-rpt-container');

                receiptContainer.empty();

                receiptContainer.html(receipt);

                await new Promise((resolve) => setTimeout(resolve, 100));

                window.print();

            } catch (_err) {

                await this.showPopup('ErrorPopup', {

                    title: this.env._t('Printing is not supported on some browsers'),

                    body: this.env._t(

                        'Printing is not supported on some browsers due to no default printing protocol ' +

                            'is available. It is possible to print your tickets by making use of an IoT Box.'

                    ),

                });

            }

I check every thing and it's ok but the print preview every time came empty 
can any one help me in this 

0
Portretas
Atmesti
Portretas
S.A. Methsiri Madusanka Sooriyaarachchi
Best Answer

The issue you're encountering with the print preview coming up empty might be due to the timing of the window.print() function. The DOM might not be fully rendered or updated when the print command is triggered. Here are a few steps you can take to ensure the HTML content is properly rendered before the print preview is triggered:

Possible Solutions

  1. Ensure the DOM is Fully Updated:
    • Instead of using a simple setTimeout, you can use requestAnimationFrame to ensure that the DOM update has been fully rendered before triggering the print.
    javascriptCopy codeasync _printWeb(receipt) {
        try {
            const receiptContainer = $(this.el).find('.pos-cash-rpt-container');
    
            receiptContainer.empty();
            receiptContainer.html(receipt);
    
            // Wait for the next frame to ensure the DOM is updated
            await new Promise(resolve => requestAnimationFrame(resolve));
    
            window.print();
        } catch (_err) {
            await this.showPopup('ErrorPopup', {
                title: this.env._t('Printing is not supported on some browsers'),
                body: this.env._t(
                    'Printing is not supported on some browsers due to no default printing protocol ' +
                    'is available. It is possible to print your tickets by making use of an IoT Box.'
                ),
            });
        }
    }
    
  2. Force a Reflow Before Printing:
    • Sometimes, forcing a reflow of the document can help ensure that all changes are rendered before printing. You can do this by accessing certain properties (like offsetHeight) that trigger a reflow.
    javascriptCopy codeasync _printWeb(receipt) {
        try {
            const receiptContainer = $(this.el).find('.pos-cash-rpt-container');
    
            receiptContainer.empty();
            receiptContainer.html(receipt);
    
            // Force reflow
            receiptContainer[0].offsetHeight;
    
            await new Promise((resolve) => setTimeout(resolve, 100));
    
            window.print();
        } catch (_err) {
            await this.showPopup('ErrorPopup', {
                title: this.env._t('Printing is not supported on some browsers'),
                body: this.env._t(
                    'Printing is not supported on some browsers due to no default printing protocol ' +
                    'is available. It is possible to print your tickets by making use of an IoT Box.'
                ),
            });
        }
    }
    
  3. Check for Browser Compatibility:
    • Make sure that the browser you're using supports the window.print() function as expected. Sometimes, certain browsers might have issues with printing, especially in a POS environment. Testing on different browsers can help identify if the problem is browser-specific.
  4. Debugging the Receipt Container:
    • Add some logging or debugging to ensure that the receiptContainer.html(receipt) is indeed populating the container with the correct content before printing.
    javascriptCopy codeconsole.log(receipt); // Check if the receipt content is correct
    console.log(receiptContainer.html()); // Check if the container is populated with the content
    

If the print preview continues to show up empty after trying these solutions, you may need to explore alternative approaches to printing, such as using the Odoo IoT Box for more reliable printing in POS environments.

2
Portretas
Atmesti
ahmed mohamady
Autorius

thank you it's working

Enjoying the discussion? Don't just read, join in!

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

Registracija
Related Posts Replies Rodiniai Veikla
How to add special JavaScript code to a from view
javascript odoo16
Portretas
Portretas
1
rugs. 24
2115
How to hide "section-financials" from the ProductInfoPopup in POS Screen Solved
javascript xml odoo16
Portretas
Portretas
2
liep. 24
1977
how to inherit the BarcodeModel in odoo 16 Solved
javascript owl odoo16
Portretas
Portretas
1
rugs. 24
3406
override method in javascript class class in odoo 16 Solved
javascript inheritance odoo16
Portretas
Portretas
Portretas
3
geg. 24
4371
[@$%$AviancaTeResponde$%$@]¿Cómo se llama Avianca en Colombia?
javascript
Portretas
0
lapkr. 25
3
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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