generate zugferd-pdf
This commit is contained in:
parent
695e60dea8
commit
fafcbe799d
5 changed files with 171 additions and 29 deletions
|
@ -78,14 +78,48 @@ class RunXRechnungReport(Wizard):
|
|||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
WizRepStart = pool.get('account_invoice_xrechnung.runrep.start')
|
||||
Configuration = pool.get('account.configuration')
|
||||
|
||||
cfg1 = Configuration.get_singleton()
|
||||
invoice = Invoice.browse([context.get('active_id', -1)])
|
||||
result = {
|
||||
'edocument': WizRepStart.default_edocument(),
|
||||
'invoice': context.get('active_id', -1),
|
||||
'state': invoice[0].state if invoice else ''}
|
||||
if cfg1 and cfg1.xrechn_default:
|
||||
result['edocument'] = cfg1.xrechn_default
|
||||
return result
|
||||
|
||||
def generate_invoice_reports(self, data):
|
||||
""" generate missing reports and store to db
|
||||
|
||||
Args:
|
||||
data (dict): report-data
|
||||
"""
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
XReport = pool.get('account_invoice_xrechnung.export', type='report')
|
||||
|
||||
invoices = Invoice.search([
|
||||
('id', '=', data['invoice']),
|
||||
('type', '=', 'out')])
|
||||
to_generate = [x.id for x in invoices if not x.invoice_report_cache]
|
||||
|
||||
if to_generate:
|
||||
report_action = XReport.get_used_report()
|
||||
|
||||
# run selected report on invoices w/o stored report-data
|
||||
data2 = {}
|
||||
data2.update(data)
|
||||
data2['action_id'] = report_action.id
|
||||
data2['model'] = report_action.model
|
||||
data2['id'] = to_generate[0]
|
||||
data2['ids'] = to_generate
|
||||
|
||||
RepInvoice = pool.get(report_action.report_name, type='report')
|
||||
with Transaction().set_context({'with_rec_name': False}):
|
||||
RepInvoice.execute(to_generate, data2)
|
||||
|
||||
def do_export(self, action):
|
||||
""" run export
|
||||
"""
|
||||
|
@ -93,9 +127,17 @@ class RunXRechnungReport(Wizard):
|
|||
raise UserError(gettext(
|
||||
'account_invoice_xrechnung.msg_invoice_must_posted',
|
||||
invname=self.start.invoice.rec_name))
|
||||
return action, {
|
||||
|
||||
data = {
|
||||
'invoice': self.start.invoice.id,
|
||||
'edocument': self.start.edocument,
|
||||
'as_zip': self.start.as_zip}
|
||||
|
||||
# if zugferd - generate missing report-cache-items
|
||||
if data['edocument'] == 'edocument.facturxext.invoice-ferd':
|
||||
# pdf is stored to db
|
||||
self.generate_invoice_reports(data)
|
||||
|
||||
return action, data
|
||||
|
||||
# end RunXRechnungReport
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue