Collegare OpenERP alle stampanti di CUPS: base_report_to_printer

Premessa

Una funzionalità spesso richiesta dagli utilizzatori di OpenERP consiste nella possibilità di inviare i report alle stampanti di sistema, in modo da stamparli direttamente su carta.

In OpenERP 5 questo era stato implementato nel modulo printjob che, tra le altre cose, permetteva appunto di inviare automaticamente i report alle stampanti di CUPS. Con l’uscita di OpenERP 6, il modulo ha smesso di funzionare. A quel punto, uno degli autori di printjob disse che non avrebbe portato il modulo alla versione 6 di OpenERP, e così molti utenti rimasero a bocca asciutta.

Recentemente ho ripreso in mano la questione e, dopo aver analizzato i problemi di porting di printjob ad OpenERP 6, ho deciso di realizzare un modulo che estrapolasse le funzionalità più importanti di printjob e si adattasse meglio ai metodi di stampa di OpenERP 6. Così nacque base_report_to_printer.

Configurazione

Il modulo base_report_to_printer è scaricabile da apps.openerp.com oppure direttamente dal nostro code repository. Una volta installato comparirà il menu Printing.

La prima cosa da fare è caricare in OpenERP le stampanti di CUPS. Esiste un wizard che le recupera automaticamente. E’ sufficiente cliccare su Update Printers from CUPS e le stampanti compariranno nella lista delle stampanti disponibili.

Il passo successivo è configurare i report da inviare alle stampanti.

Nel form del report è quindi possibile stabilire il comportamento del sistema al momento della generazione del report.

Si può indicare un comportamento globale, oppure distinguerlo a seconda dell’utente che sta stampando. Nell’esempio, il comportamento globale prevede di inviare il report direttamente al client (Send to Client), quindi senza mandarlo alla stampante. Se però a stampare è l’utente elbati, il report sarà inviato alla stampante selezionata (Send to Printer).

E’ anche possibile definire un comportamento di default associato all’utente, in modo da stabilire se uno certo utente, quando non diversamente indicato, voglia sempre inviare i report ad una specifica stampante.

Terminata la configurazione, sarà sufficiente cliccare sul pulsante di stampa associato al report (o lanciare il report da un wizard o qualunque altra cosa) ed il sistema invierà automaticamente il report alla stampante prestabilita.

Buona stampa.

Facebook Twitter Linkedin Digg Delicious Reddit Stumbleupon Tumblr Posterous Email Snailmail

Written by on domenica, ottobre 9th, 2011

Lorenzo Battistini
OpenERP addicted
GitHub profile: https://github.com/eLBati
Launchpad profile: https://launchpad.net/~elbati
Linkedin profile: http://www.linkedin.com/in/elbati
------------------------------------------------
Agile Business Group
  • http://twitter.com/hawodi Hassan Awodi

    Hello Elbati, thanks for this module. Does this work with the web client? 

    • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

      Hello Hassan, the module runs server-side, so it is supposed to work independently from the client

      • http://twitter.com/hawodi Hassan Awodi

        Thanks Lorenzo. I tried installing the module but keep getting this error:  import cupsImportError: No module named cupsIf it may help, I have cups installed on ubuntu 10.04 server.

        • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

          Did you try installing ‘python-cups’ or ‘python-cupshelpers’?

          • http://twitter.com/hawodi Hassan Awodi

            I didn’t have python-cups installed! Thanks. It’s installed now.

          • ashok dudla

            have you installed python-cups in windows ? if its done please share the proper process please

  • Christian Werner

    Hi,

    after updating openerp from 6.1rc1 to 6.1.1 no reports will be printed. The configuration is correct because before updating all works right.

    Do you have an Idea?

     

    • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

      Did you perform
      –update=all
      ?

      • Christian Werner

         yes I have also installed a new database with demodata. With this database I have the same issue

        • Christian Werner

           the printers which are installed in cups are available in openerp an I can configure openerp report to a printer. If I change something it will be saved.
          But the Reports didn’t print.

        • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

           I’m not able to reproduce your problem, sorry

          • Christian Werner

             Do you print from web-client?

          • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

             From both GTK and web

          • Christian Werner

            can you look fpr the configuration of my demo-data?
            i could send you the login via mail

          • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

            Although this module is free software distributed to the community, I’m afraid I cannot provide free support on specific issues.

          • Christian Werner

            we are willing to pay for support.
            please contact me via mail

      • Clinton Wright

         Hi Lorenzo, where do you write –update=all into? I can imagine into terminal but with what command? openerp-server?

  • Lajujula

    Nice plugin, il there a way to avoid the resulting PDF to pop-up on the client side ?

    Regards

  • Clinton Wright

    Dear eLBati, Please could you direct me how to install this module. I have downloaded the module and put it into my /opt/openerp/server/openerp/addons/ folder and I have set the permissions correctly (I installed the source files for OpenERP 6.1-1). I have found another location in /usr/local/lib/pymodules/python2.7/dist-packages/openerp/addons and add the module (unzipped) in this folder as well. I searched my entire file system for any other addons folders without any results. So this seems to be all the places where the addons file could possibly be. I have checked and doubled check permissions (Using Ubuntu Linux 12.04) on the Folder and Files and when I log into OpenERP and goto modules update module list, it shows nothing added. In your write up you mention nothing about how to install this module. Please could you mention how to install it. Thank you kindly. Clinton Wright

  • Aj

    Hi,
    Is this module work on Windows ?

    • Franco Tampieri

       Hi Aj,

      at the moment we support only linux installation, but if you want help us to test with windows you are welcome.

      Best Regards

      Franco

      • Aj

        Hi Franco,
        I’ve tested it on Windows 7. I’ve get an error about CUPS… After some researches, I found that python-cups should be installed. But I’m on Windows, and I have not find a way to install CUPS on Windows…

        Is it Possible ?

        • Franco Tampieri

           Hi Aj, on windows there isn’t a release of CUPS printer Server, but there is the lpr command, can you confirm that?

      • justin

        i have a windows install that we are testing, i would like to help in the testing for windows print server

  • Christian Fast

    Hello Lorenzo!
    How can i reach CUPS if its not running local? We have a own printer-server.
    Thanks a lot in advance!
    Best regards,
    Christian

    • ChristianFast

      ok got it!

      just add server to update_printers_status:
      cups.setUser(‘root’)
      cups.setServer(‘xxx.xxx.xxx.xxx’)

      br christian

      • Charles

        Hi how we can set these things in code my user is root and server is zbeanztech.myvnc.com.We no need password for this connection?

  • Moises

    Please I need help, I installed the cups, I’ve also installed the module, I recognize the printer (Epson LX300) and configured correctly Send to Printer as it suggests, however when I print the facura always download the file pdf on my pc does not respond to the command to travez printed to the cups, any suggestions?

    • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

      Maybe your connection with CUPS is broken

      • ashok dudla

        i have installed the pycups in Ubuntu when i am printing the print its again download pdf but i want to direct go to printer please if anyones knows please share the process…

  • http://duckprince.blogspot.com/ duckprince

    does it work with openerp 7.0?

    • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

      Not ported yet.

      By the way, module has been moved to ‘OpenERP Report – Printing and Sending’ project ( https://launchpad.net/report-print-send ). There you’ll find future updates.

      • mamak111

        Any idea when or if it is going to be done for ver 7.0

  • Florent THOMAS

    Hy,

    This plugin is perfect.
    One additionnal question : is it possible to print twice a document thanks to that?

    regards

    • http://planet.domsense.com/en/author/elbati/ Lorenzo Battistini

      Sending the document to 2 printers at the same time?
      You can do that by CUPS.

  • dave

    hello Lorenzo , I am using your module now and modified the code so that you can have multiple prints on different printers….my question is , is it possible possible to stop openERP from downloading the document while printing? because my webclient will downnload the PDF anyway

  • dave

    hello, I would like to extend the module, to have a default value for the user field, so that when I add a printing action it applies to all the users, do you have any idea…..

  • http://krazeekrazees.com/ Ziggy Kratzer

    Hello, I can’t seem to get this working. I have installed this module on OpenERP 6.1 running on Ubuntu 12.04. I setup my CUPS print server with 2 printers, both of which I can print to remotely and locally. Then I followed this guide and both printers were found. I setup my report and my user to Send to Printer, but when I try to print it opens the pdf file, but it does not print. I’ve tried both printers and I can print to the CUPS printer manually, once the pdf file is opened, but it doesn’t print automatically.

  • Amit Parik

    Hello Lorenzo,

    Does this module work for matrix printer?
    And Have you migrate this module on v7?

    Thank you!
    Amit Parik