exprt wizard begonnen
This commit is contained in:
parent
7b160d84af
commit
00dd70e877
7 changed files with 142 additions and 8 deletions
|
@ -4,20 +4,62 @@
|
|||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.wizard import Wizard, StateAction
|
||||
from trytond.wizard import Wizard, StateView, StateReport
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
sel_edocument = [
|
||||
('edocument.xrechnung.invoice', 'XRechnung UBL Invoice 2.1.1'),
|
||||
('edocument.uncefact.invoice', 'CII CrossIndustryInvoice D16B'),
|
||||
]
|
||||
|
||||
|
||||
class RunXRechnungReportStart(ModelView):
|
||||
'eDocument Report'
|
||||
__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,
|
||||
selection=sel_edocument)
|
||||
|
||||
@classmethod
|
||||
def default_edocument(cls):
|
||||
""" default xrechnung
|
||||
"""
|
||||
return 'edocument.xrechnung.invoice'
|
||||
|
||||
# end RunXRechnungReportStart
|
||||
|
||||
|
||||
class RunXRechnungReport(Wizard):
|
||||
'XRechnung Report'
|
||||
'eDocument Report'
|
||||
__name__ = 'account_invoice_xrechnung.runrep'
|
||||
|
||||
start_state = 'open_'
|
||||
#report_ = StateReport('cashbook.reprecon')
|
||||
open_ = StateAction('account_invoice.act_invoice_form')
|
||||
export = StateReport('account_invoice_xrechnung.export')
|
||||
open_ = 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='Export', state='export', icon='tryton-export'),
|
||||
],
|
||||
)
|
||||
|
||||
def do_open_(self, action):
|
||||
def default_open_(self):
|
||||
""" set defaults
|
||||
"""
|
||||
context = Transaction().context
|
||||
|
||||
result = {
|
||||
'edocument': 'edocument.xrechnung.invoice',
|
||||
'invoice': context.get('active_id', -1),
|
||||
}
|
||||
return result
|
||||
|
||||
def do_export(self, action):
|
||||
""" run form
|
||||
"""
|
||||
pool = Pool()
|
||||
|
@ -29,7 +71,8 @@ class RunXRechnungReport(Wizard):
|
|||
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, {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue