diff --git a/addons/account_greek_fiscal/__init__.py b/addons/account_greek_fiscal/__init__.py index 4b0438f7d35..bde4b31195c 100644 --- a/addons/account_greek_fiscal/__init__.py +++ b/addons/account_greek_fiscal/__init__.py @@ -22,6 +22,7 @@ import fiscal_prints import account_invoice_print +import ir_actions_report import wizard import report diff --git a/addons/account_greek_fiscal/account_fiscalgr_view.xml b/addons/account_greek_fiscal/account_fiscalgr_view.xml index c2894ffed07..7144aaf059a 100644 --- a/addons/account_greek_fiscal/account_fiscalgr_view.xml +++ b/addons/account_greek_fiscal/account_fiscalgr_view.xml @@ -41,5 +41,18 @@ + + ir.actions.report.xml.fiscalgr_1 + ir.actions.report.xml + + form + + + + + + + + diff --git a/addons/account_greek_fiscal/account_invoice_print.py b/addons/account_greek_fiscal/account_invoice_print.py index 0de4c552a8e..90e792b8b28 100644 --- a/addons/account_greek_fiscal/account_invoice_print.py +++ b/addons/account_greek_fiscal/account_invoice_print.py @@ -78,7 +78,7 @@ class account_invoice(osv.osv): for i in invoices: if fiscalgr_obj.print_invoice(cr,uid,i,self._name,i['number'], i['property_fiscalgr_invoice_report'][0],context): self.write(cr,uid,i['id'],{'state':'printed'}) - logger.notifyChannel("fiscalgr", netsvc.LOG_INFO, 'printed invoice %s'%i['number']) + logger.notifyChannel("fiscalgr", netsvc.LOG_INFO, 'printed invoice ref. %s'%i['number']) return True diff --git a/addons/account_greek_fiscal/fiscal_prints.py b/addons/account_greek_fiscal/fiscal_prints.py index edc6ea0bfd4..0d4bc4a5fd5 100644 --- a/addons/account_greek_fiscal/fiscal_prints.py +++ b/addons/account_greek_fiscal/fiscal_prints.py @@ -39,9 +39,13 @@ class fiscal_print(osv.osv): _defaults = { } - def _print_fiscal(self,cr,uid,report_id,title,format,content,context=None): + def _print_fiscal(self,cr,uid,report_id,title,format,content,printer='Forol',copies=1,context=None): import tempfile import os + 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')) @@ -51,25 +55,24 @@ class fiscal_print(osv.osv): try: import cups except: - common.message(_('Cannot talk to cups, please install pycups')) - return False + 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,{}) + #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: print 'Created job %d'% job fprn=self.create(cr,uid,{'cups_jobid':job,'name':title,'report':report_id},context) return True else: - common.message(_('Cannot print at printer %s')%PRINTER) + raise Exception(_('Cannot print at printer %s')%printer) return False def print_invoice(self,cr,uid,inv_data,inv_model,inv_title, inv_report, context): logger=netsvc.Logger() - logger.notifyChannel("fiscalgr", netsvc.LOG_INFO, 'printing one %s invoice '%(type(inv_report))) + logger.notifyChannel("fiscalgr", netsvc.LOG_DEBUG, 'printing one %s invoice '%(inv_report)) report_obj=self.pool.get('ir.actions.report.xml') rep= report_obj.read(cr,uid,inv_report,[]) if (rep['model']!=inv_model or rep['report_type'] != 'txt'): @@ -83,7 +86,9 @@ class fiscal_print(osv.osv): if (format != 'txt'): raise Exception("Invoice format is not txt, strange") # print result - return self._print_fiscal(cr,uid,inv_report,inv_title,format,result.decode('utf-8'),context) + return self._print_fiscal(cr,uid,inv_report,title=inv_title,format=format, + content=result.decode('utf-8'),printer=rep['printer'], + copies=rep['copies'],context=context) #self._reports[id]['result'] = result #self._reports[id]['format'] = format diff --git a/addons/account_greek_fiscal/ir_actions_report.py b/addons/account_greek_fiscal/ir_actions_report.py new file mode 100644 index 00000000000..7b257d23020 --- /dev/null +++ b/addons/account_greek_fiscal/ir_actions_report.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields, osv +# import netsvc + +class report_xml(osv.osv): + _inherit = "ir.actions.report.xml" + _columns = { + # states={'open':[('readonly',False)]} + 'printer': fields.char('Printer', size=50, help="Preferred printer for this report. Useful for server-side printing."), + 'copies': fields.integer('Copies', help="Default number of copies."), + } + +report_xml() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file