Linux users who are working with the GTK-client, should first create a preview before they can really print. Below you have a piece of code that change that!
The code first get the installed printers on your system and list them to you with the same selectionbox when you click on the action button. Select your printer an click on "OK" will send your report directly to your printer. NOTE: It's only working on Linux! I tested it with Fedora 9 and Ubuntu 8.04. Change the file <yourclient>/bin/printer/printer.py --- OpenERP-trunk/client/bin/printer/printer.py 2008-07-24 16:32:42.000000000 +0200 +++ client/bin/printer/printer.py 2008-07-28 15:34:47.000000000 +0200 @@ -174,8 +174,46 @@ printer = Printer() def print_linux_filename(filename): - common.message(_('Linux Automatic Printing not implemented.\nUse preview option !')) + # import extra functions for the printing process + from subprocess import Popen, PIPE + # execute 'lpstat -a' to get the printers installed on your system + # and split them into a list + s = Popen(['lpstat', '-a'], stdout=PIPE).stdout.read().split('\n') + + # remove the latest record from the list, due to the splitfunction + s.pop() + + printerlist = {} + for printer in s: + # Get the printername and add it to the dicionary + printername = printer.split() + printerlist[printername[0] ] = printername[0] + + # popup a selectionlist, so you can select your printer + selectedPrinter = common.selection(_('Select a printer'), printerlist , True) + + # define the printcommand with the selected printer + printcommand = 'lpr -P ' + selectedPrinter[0] + + # try to open the file and printer + try: + pf = open(filename, 'r') + printer = os.popen(printcommand , 'w') + + try: + # read the file + printdata = pf.read() + # and parse it to the printer + printer.write(printdata) + finally: + # close the printer and file + printer.close() + pf.close() + except IOError: + raise + + def print_w32_filename(filename): import win32api win32api.ShellExecute (0, "print", filename, None, ".", 0) I hope Tiny will add this piece of code to the trunk. Eddy _______________________________________________ Tinyerp-users mailing list http://tiny.be/mailman/listinfo/tinyerp-users
