From 118c1d73eeafa1202358351ecf9ccc8df98c363e Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Thu, 28 Oct 2010 15:24:12 +0300 Subject: [PATCH] Greek fiscal prints: use locale's encoding. Now that the driver understands encodings, try to use the correct one, from the system's locale. bzr revid: p_christ@hol.gr-20101028122412-dmqn090w8z366uli --- addons/account_greek_fiscal/fiscal_prints.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/account_greek_fiscal/fiscal_prints.py b/addons/account_greek_fiscal/fiscal_prints.py index 81e475aa4b8..0443c3440fd 100644 --- a/addons/account_greek_fiscal/fiscal_prints.py +++ b/addons/account_greek_fiscal/fiscal_prints.py @@ -46,24 +46,25 @@ class fiscal_print(osv.osv): def _print_fiscal(self,cr,uid,report_id,title,format,content,printer=False,copies=1,context=None): import tempfile import os + import locale if not printer: raise Exception(_('No printer specified for report')) if not copies: copies=1 (fileno, fp_name) = tempfile.mkstemp('.'+format, 'openerp_') fp = file(fp_name, 'wb+') - fp.write(content.encode('iso8859-7')) + try: + encoding = locale.getdefaultlocale()[1] + except: + encoding = 'UTF-8' + fp.write(content.encode(encoding)) fp.close() os.close(fileno) - PRINTER='Forol2' try: import cups except: raise Exception(_('Cannot talk to cups, please install pycups')) ccon = cups.Connection() - #attrs=ccon.getPrinterAttributes(name=PRINTER) - #print "Located \"%s\" at a v%s CUPS server" %(attrs['printer-make-and-model'],attrs['cups-version']) - #print 'Trying to print %s at %s'%(fp_name,PRINTER) job = ccon.printFile(printer,fp_name,title,{'copies': str(copies)}) os.unlink(fp_name) if job: