Linking OpenERP to CUPS printers: base_report_to_printer

Introduction

OpenERP users often require the possibility to send reports to system printers, in order to print the reports on paper directly.

In OpenERP 5, this functionality was implemented by prinjob module. It provided several functionalities, one of these was to automatically send reports to CUPS printers. After the release of OpenERP 6, the module stopped working. At that point, one of the printjob’s authors said that he wouldn’t have ported the module to OpenERP 6, so many users was left empty-handed.

Recently, I’ve picked up the issue again and, after having analysed the problems of porting printjob to OpenERP 6, I decided to realize a module that would have extrapolated the most important functionalities of printjob and better adapted to printing methods of OpenERP 6. So, base_report_to_printer was born.

Configuration

The base_report_to_printer module is downloadable from apps.openerp.com or directly from our code repository. Once you installed it, the Printing menu will appear.

First of all, you have to load CUPS printers in OpenERP. You can use a wizard that retrieves them automatically. You just have to click on Update Printers from CUPS and printers will appear within the available printers list.

In the next step you will configure the reports to send to the printers.

Through the report form you can define the system’s behaviour while producing the report.

You can set a global behaviour, or differentiate it according to the user who’s printing. In the example, the global behaviour defines to send the report to client directly (Send to Client), therefore without sending it to the printer. But if user elbati is printing, the report will be sent to the selected printer (Send to Printer).

You can also define a default behaviour associated to the user, in order to establish whether a certain user, when not differently set, wants to send the reports always to a specific printer or not.

After finishing the configuration, you will just have to click on printing button associated to the report (or launch the report by a wizard or whatever) and the system will automatically send the report to the previously set printer.

Happy printing.

Facebook Twitter Linkedin Digg Delicious Reddit Stumbleupon Tumblr Posterous Email Snailmail

Written by on Sunday, October 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