Fiscal: call the fiscal printing with data.
bzr revid: p_christ@hol.gr-20101028122408-revhwndxyg8b0ty6
This commit is contained in:
parent
ed9bff250a
commit
69e0367ceb
|
@ -30,7 +30,7 @@
|
|||
""",
|
||||
"website" : "http://www.hellug.gr",
|
||||
"category" : "Generic Modules/Accounting",
|
||||
"init_xml" : [
|
||||
"init_xml" : [ "account_invoice_data.xml",
|
||||
],
|
||||
"demo_xml" : [
|
||||
],
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- default properties -->
|
||||
<record model="ir.property" id="property_fiscalgr_invoice_report_out">
|
||||
<field name="name">property_fiscalgr_invoice_report</field>
|
||||
<field name="fields_id" search="[('model','=','account.invoice'),('name','=','property_fiscalgr_invoice_report')]"/>
|
||||
<field name="value" eval="'ir.actions.report.xml,'+str(1)"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -37,6 +37,9 @@ class account_invoice(osv.osv):
|
|||
('cancel','Canceled'),
|
||||
('printed','Printed'),
|
||||
],'State', select=True, readonly=True),
|
||||
'property_fiscalgr_invoice_report': fields.property( 'ir.actions.report.xml', type='many2one',
|
||||
relation='ir.actions.report.xml', string="Fiscal report template", method=True,
|
||||
view_load=True, group_name="Reports"),
|
||||
}
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
if default is None:
|
||||
|
@ -56,7 +59,8 @@ class account_invoice(osv.osv):
|
|||
def action_fiscalgr_print(self, cr, uid, ids, *args):
|
||||
fiscalgr_obj = self.pool.get('account.fiscalgr.print')
|
||||
logger = netsvc.Logger()
|
||||
invoices = self.read(cr, uid, ids, ['id','number','state','type','fiscalgr_print'])
|
||||
invoices = self.read(cr, uid, ids, ['id','number','state','type',
|
||||
'fiscalgr_print','property_fiscalgr_invoice_report'])
|
||||
# First, iterate once to check if the invoices are valid for printing.
|
||||
for i in invoices:
|
||||
if not i['number']:
|
||||
|
@ -65,13 +69,15 @@ class account_invoice(osv.osv):
|
|||
raise osv.except_osv(_('Cannot print!'), _('Cannot print invoice \"%s\" which is not open.')%i['number'])
|
||||
if (not i['type'] or (i['type'][0:3] != 'out')):
|
||||
raise osv.except_osv(_('Cannot print!'), _('Cannot print invoice \"%s\", it is not an outgoing one.')%i['number'])
|
||||
if not i['property_fiscalgr_invoice_report']:
|
||||
raise osv.except_osv(_('Cannot print!'), _('Cannot locate report setting for fiscal printing!'))
|
||||
if i['fiscalgr_print']:
|
||||
raise osv.except_osv(_('Cannot print!'), _('Cannot print invoice \"%s\" which is already printed !')%i['number'])
|
||||
#raise osv.except_osv(_('Invalid action !'), _('Cannot print such an invoice !'))
|
||||
|
||||
#Then, iterate again, and issue those invoices for printing
|
||||
for i in invoices:
|
||||
if fiscalgr_obj.print_invoice(cr,uid,i,self._name, i['type']):
|
||||
if fiscalgr_obj.print_invoice(cr,uid,i,self._name, i['property_fiscalgr_invoice_report']):
|
||||
self.write(cr,uid,i['id'],{'state':'printed'})
|
||||
logger.notifyChannel("fiscalgr", netsvc.LOG_INFO, 'printed invoice %s'%i['number'])
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!--<wizard string="Issue Invoice"
|
||||
model="account.invoice"
|
||||
name="wizard.fiscalgr_invoice_print"
|
||||
id="wizard_fiscalgr_invoice_print"
|
||||
keyword="client_print_multi"
|
||||
/> -->
|
||||
</data>
|
||||
</openerp>
|
|
@ -38,9 +38,9 @@ class fiscal_print(osv.osv):
|
|||
}
|
||||
_defaults = {
|
||||
}
|
||||
def print_invoice(self,cr,uid,inv_data,inv_model, inv_type):
|
||||
def print_invoice(self,cr,uid,inv_data,inv_model, inv_report):
|
||||
logger=netsvc.Logger()
|
||||
logger.notifyChannel("fiscalgr", netsvc.LOG_INFO, 'printing one %s invoice '%inv_type)
|
||||
logger.notifyChannel("fiscalgr", netsvc.LOG_INFO, 'printing one %s invoice '%(type(inv_report)))
|
||||
|
||||
fiscal_print()
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2008 P. Christeas. All Rights Reserved
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import invoice_fiscalgr_print
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2008 P. Christeas. 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
import time
|
||||
import datetime
|
||||
import pooler
|
||||
|
||||
# *-* this code is still useless..
|
||||
|
||||
invoice_form = """<?xml version="1.0"?>
|
||||
<form string="Confirm">
|
||||
<label string="Please confirm if you really want to issue this invoice."/>
|
||||
<label string="After issuing, it becomes a legal document."/>
|
||||
</form>"""
|
||||
|
||||
invoice_fields = { }
|
||||
|
||||
def _invoice_print(self, cr, uid, data, context):
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for id in data['ids']:
|
||||
common.message("aaa: %d"%id)
|
||||
#wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_open', cr)
|
||||
return {}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':invoice_form, 'fields':invoice_fields,
|
||||
'state':[('end','Cancel'),('print','Print')]},
|
||||
},
|
||||
'print': {
|
||||
'actions': [_invoice_print],
|
||||
'result': {'type':'state' , 'state':'end'},
|
||||
},
|
||||
}
|
||||
|
||||
wizard_report('wizard.fiscalgr.invoice_print')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue