diff --git a/.hgignore b/.hgignore
index 201e288..796d378 100644
--- a/.hgignore
+++ b/.hgignore
@@ -3,3 +3,4 @@ build/*
dist/*
mds_account_invoice_xrechnung.egg-info/*
__pycache__/*
+locale/convert_de2en.py
diff --git a/__init__.py b/__init__.py
index 0c9d2d3..8676653 100644
--- a/__init__.py
+++ b/__init__.py
@@ -6,6 +6,7 @@
from trytond.pool import Pool
from .wizard_runreport import RunXRechnungReport, RunXRechnungReportStart
from .invoice import InvoiceLine
+from .xreport import XReport
def register():
Pool.register(
@@ -15,3 +16,6 @@ def register():
Pool.register(
RunXRechnungReport,
module='account_invoice_xrechnung', type_='wizard')
+ Pool.register(
+ XReport,
+ module='account_invoice_xrechnung', type_='report')
diff --git a/locale/de.po b/locale/de.po
new file mode 100644
index 0000000..e877610
--- /dev/null
+++ b/locale/de.po
@@ -0,0 +1,59 @@
+#
+msgid ""
+msgstr "Content-Type: text/plain; charset=utf-8\n"
+
+
+#############
+# ir.action #
+#############
+msgctxt "model:ir.action,name:act_wizard_report"
+msgid "eDocument Export"
+msgstr "eDocument Export"
+
+msgctxt "model:ir.action,name:report_edocument"
+msgid "eDocument Export"
+msgstr "eDocument Export"
+
+
+##########################################
+# account_invoice_xrechnung.runrep.start #
+##########################################
+msgctxt "model:account_invoice_xrechnung.runrep.start,name:"
+msgid "eDocument Export"
+msgstr "eDocument Export"
+
+msgctxt "field:account_invoice_xrechnung.runrep.start,invoice:"
+msgid "Invoice"
+msgstr "Rechnung"
+
+msgctxt "field:account_invoice_xrechnung.runrep.start,edocument:"
+msgid "Type"
+msgstr "Typ"
+
+msgctxt "field:account_invoice_xrechnung.runrep.start,as_zip:"
+msgid "ZIP-File"
+msgstr "ZIP-Datei"
+
+
+####################################
+# account_invoice_xrechnung.runrep #
+####################################
+msgctxt "model:account_invoice_xrechnung.runrep,name:"
+msgid "eDocument Export"
+msgstr "eDocument Export"
+
+msgctxt "wizard_button:account_invoice_xrechnung.runrep,start,end:"
+msgid "Cancel"
+msgstr "Abbruch"
+
+msgctxt "wizard_button:account_invoice_xrechnung.runrep,start,export:"
+msgid "Export"
+msgstr "Export"
+
+
+####################################
+# account_invoice_xrechnung.export #
+####################################
+msgctxt "model:account_invoice_xrechnung.export,name:"
+msgid "eDocument Export"
+msgstr "eDocument Export"
diff --git a/locale/en.po b/locale/en.po
new file mode 100644
index 0000000..3e16682
--- /dev/null
+++ b/locale/en.po
@@ -0,0 +1,36 @@
+#
+msgid ""
+msgstr "Content-Type: text/plain; charset=utf-8\n"
+
+msgctxt "model:ir.action,name:act_wizard_report"
+msgid "eDocument Export"
+msgstr "eDocument Export"
+
+msgctxt "model:ir.action,name:report_edocument"
+msgid "eDocument Export"
+msgstr "eDocument Export"
+
+msgctxt "model:account_invoice_xrechnung.runrep.start,name:"
+msgid "eDocument Export"
+msgstr "eDocument Export"
+
+msgctxt "field:account_invoice_xrechnung.runrep.start,invoice:"
+msgid "Invoice"
+msgstr "Invoice"
+
+msgctxt "field:account_invoice_xrechnung.runrep.start,edocument:"
+msgid "Type"
+msgstr "Type"
+
+msgctxt "model:account_invoice_xrechnung.runrep,name:"
+msgid "eDocument Export"
+msgstr "eDocument Export"
+
+msgctxt "wizard_button:account_invoice_xrechnung.runrep,start,end:"
+msgid "Cancel"
+msgstr "Cancel"
+
+msgctxt "wizard_button:account_invoice_xrechnung.runrep,start,export:"
+msgid "Export"
+msgstr "Export"
+
diff --git a/report/export.fodt b/report/export.fodt
new file mode 100644
index 0000000..f9df621
--- /dev/null
+++ b/report/export.fodt
@@ -0,0 +1,251 @@
+
+
+
+ 2017-10-20T23:40:51.940000000LibreOffice/6.0.7.3$Linux_X86_64 LibreOffice_project/00m0$Build-30P0D
+
+
+ 0
+ 0
+ 25058
+ 20851
+ true
+ false
+
+
+ view2
+ 6720
+ 2501
+ 0
+ 0
+ 25056
+ 20849
+ 0
+ 1
+ false
+ 100
+ false
+ false
+
+
+
+
+ false
+
+ false
+ false
+ false
+ false
+ false
+ true
+ false
+ true
+ true
+ false
+
+ true
+
+ false
+ false
+ true
+ false
+ true
+ false
+ 3071
+ false
+ false
+ true
+ false
+ false
+ true
+ true
+ true
+ true
+ true
+ true
+ false
+ false
+ 1
+ false
+ false
+ false
+
+ false
+ false
+
+ false
+ false
+ false
+
+ false
+ 0
+ false
+
+ 0
+ true
+ false
+ true
+ false
+ false
+ false
+ true
+ false
+ false
+ false
+ true
+ 20402
+ true
+ false
+ false
+ false
+ high-resolution
+ true
+ true
+ true
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ true
+ false
+ 0
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file is not used :-)
+
+
+
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 046579a..d50543f 100644
--- a/setup.py
+++ b/setup.py
@@ -42,7 +42,7 @@ with open(path.join(here, 'versiondep.txt'), encoding='utf-8') as f:
major_version = 6
minor_version = 0
-requires = []
+requires = ['python-slugify']
for dep in info.get('depends', []):
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
if dep in modversion.keys():
@@ -89,7 +89,7 @@ setup(name='%s_%s' % (PREFIX, MODULE),
'Programming Language :: Python :: 3.8',
],
- keywords='tryton account invoice xrechnung',
+ keywords='tryton account invoice xrechnung edocument',
package_dir={'trytond.modules.%s' % MODULE: '.'},
packages=[
'trytond.modules.%s' % MODULE,
diff --git a/tryton.cfg b/tryton.cfg
index f77a33b..ffc3e07 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -6,3 +6,4 @@ depends:
edocument_xrechnung
xml:
wizard_runreport.xml
+ xreport.xml
diff --git a/view/wizard_form.xml b/view/wizard_form.xml
index d301445..10295d1 100644
--- a/view/wizard_form.xml
+++ b/view/wizard_form.xml
@@ -8,4 +8,7 @@ full copyright notices and license terms. -->
+
+
+
diff --git a/wizard_runreport.py b/wizard_runreport.py
index 2e58629..dc86ac7 100644
--- a/wizard_runreport.py
+++ b/wizard_runreport.py
@@ -4,7 +4,7 @@
# full copyright notices and license terms.
from trytond.model import ModelView, fields
-from trytond.wizard import Wizard, StateView, StateReport
+from trytond.wizard import Wizard, StateView, StateReport, Button
from trytond.pool import Pool
from trytond.transaction import Transaction
@@ -14,15 +14,28 @@ sel_edocument = [
('edocument.uncefact.invoice', 'CII CrossIndustryInvoice D16B'),
]
+edoc_versions = {
+ 'edocument.xrechnung.invoice': 'XRechnung-2.2',
+ 'edocument.uncefact.invoice': '16B-CII',
+ }
+
+
class RunXRechnungReportStart(ModelView):
- 'eDocument Report'
+ 'eDocument Export'
__name__ = 'account_invoice_xrechnung.runrep.start'
invoice = fields.Many2One(string='Invoice', readonly=True,
model_name='account.invoice', required=True)
- edocument = fields.Selection(string='eDocument', required=True,
+ edocument = fields.Selection(string='Type', required=True,
selection=sel_edocument)
+ as_zip = fields.Boolean(string='ZIP-File')
+
+ @classmethod
+ def default_as_zip(cls):
+ """ default: True
+ """
+ return True
@classmethod
def default_edocument(cls):
@@ -34,21 +47,21 @@ class RunXRechnungReportStart(ModelView):
class RunXRechnungReport(Wizard):
- 'eDocument Report'
+ 'eDocument Export'
__name__ = 'account_invoice_xrechnung.runrep'
- start_state = 'open_'
+ start_state = 'start'
export = StateReport('account_invoice_xrechnung.export')
- open_ = StateView(
+ start = StateView(
model_name='account_invoice_xrechnung.runrep.start',
view='account_invoice_xrechnung.wiz_start_form',
buttons=[
- Button(string='Cancel', state='cleanup', icon='tryton-cancel'),
+ Button(string='Cancel', state='end', icon='tryton-cancel'),
Button(string='Export', state='export', icon='tryton-export'),
],
)
- def default_open_(self):
+ def default_start(self, fields):
""" set defaults
"""
context = Transaction().context
@@ -60,20 +73,12 @@ class RunXRechnungReport(Wizard):
return result
def do_export(self, action):
- """ run form
+ """ run export
"""
- pool = Pool()
- Invoice = pool.get('account.invoice')
- EDocument = pool.get('edocument.xrechnung.invoice')
- context = Transaction().context
-
- invoice, = Invoice.browse([context.get('active_id', -1)])
- template = EDocument(invoice)
- invoice_string = template.render('XRechnung-2.2')
- print('\n## invoice_string:', invoice_string.decode('utf8'))
- with open('x-rechnung.xml', 'wt') as fhdl:
- fhdl.write(invoice_string.decode('utf8'))
-
- return action, {}
+ return action, {
+ 'invoice': self.start.invoice.id,
+ 'edocument': self.start.edocument,
+ 'as_zip': self.start.as_zip,
+ }
# end RunXRechnungReport
diff --git a/wizard_runreport.xml b/wizard_runreport.xml
index 5170e48..ab92501 100644
--- a/wizard_runreport.xml
+++ b/wizard_runreport.xml
@@ -13,7 +13,7 @@ full copyright notices and license terms. -->
- XRechnung Report
+ eDocument Export
account_invoice_xrechnung.runrep
diff --git a/xreport.py b/xreport.py
new file mode 100644
index 0000000..fa129b2
--- /dev/null
+++ b/xreport.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+# This file is part of the cashbook-module from m-ds for Tryton.
+# The COPYRIGHT file at the top level of this repository contains the
+# full copyright notices and license terms.
+
+import zipfile
+from io import BytesIO
+from trytond.report import Report
+from trytond.pool import Pool
+from slugify import slugify
+from .wizard_runreport import edoc_versions
+
+
+class XReport(Report):
+ 'eDocument Export'
+ __name__ = 'account_invoice_xrechnung.export'
+
+ @classmethod
+ def compress_as_zip(cls, fname, data):
+ """ compress
+ """
+ content = BytesIO()
+ with zipfile.ZipFile(content, 'w') as content_zip:
+ content_zip.writestr(fname, data)
+ return content.getvalue()
+
+ @classmethod
+ def execute(cls, ids, data):
+ """ skip export-engine, run edocument-xml-convert
+ """
+ pool = Pool()
+ IrDate = pool.get('ir.date')
+ Invoice = pool.get('account.invoice')
+ EDocument = pool.get(data['edocument'])
+
+ invoice, = Invoice.browse([data['invoice']])
+ template = EDocument(invoice)
+ invoice_string = template.render(edoc_versions[data['edocument']])
+
+ file_name = slugify('%(date)s-%(descr)s' % {
+ 'date': IrDate.today().isoformat().replace('-', ''),
+ 'descr': invoice.rec_name,
+ },
+ max_length=100, word_boundary=True, save_order=True)
+
+ if data['as_zip'] == True:
+ return (
+ 'zip',
+ cls.compress_as_zip('%(fname)s.%(ext)s' % {
+ 'fname': file_name,
+ 'ext': 'xml',
+ }, invoice_string),
+ False,
+ file_name)
+ else :
+ return ('xml', invoice_string, False, file_name)
+
+# end XReport
diff --git a/xreport.xml b/xreport.xml
new file mode 100644
index 0000000..07082c9
--- /dev/null
+++ b/xreport.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ eDocument Export
+ account.invoice
+ account_invoice_xrechnung.export
+ account_invoice_xrechnung/report/export.fodt
+ odt
+
+
+
+
+