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
This commit is contained in:
parent
4f56fdd419
commit
118c1d73ee
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue