allow route-id to be optional
This commit is contained in:
parent
004f35ad13
commit
61cf85eb0b
14 changed files with 132 additions and 10 deletions
16
locale/de.po
16
locale/de.po
|
@ -35,6 +35,22 @@ msgid "X-Rechnung Route-ID"
|
||||||
msgstr "X-Rechnung Leitweg-ID"
|
msgstr "X-Rechnung Leitweg-ID"
|
||||||
|
|
||||||
|
|
||||||
|
###############
|
||||||
|
# party.party #
|
||||||
|
###############
|
||||||
|
msgctxt "view:party.party:"
|
||||||
|
msgid "X-Rechnung"
|
||||||
|
msgstr "X-Rechnung"
|
||||||
|
|
||||||
|
msgctxt "field:party.party,xrechnung_routeid:"
|
||||||
|
msgid "X-Rechnung Route-ID"
|
||||||
|
msgstr "X-Rechnung Leitweg-ID"
|
||||||
|
|
||||||
|
msgctxt "help:party.party,xrechnung_routeid:"
|
||||||
|
msgid "Enables the need for an XRechnung route ID at the party for exporting the XRechnung."
|
||||||
|
msgstr "Aktiviert die Notwendigkeit einer XRechnung-Leitweg-ID an der Partei für den Export der XRechnung."
|
||||||
|
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# account.tax #
|
# account.tax #
|
||||||
###############
|
###############
|
||||||
|
|
16
locale/en.po
16
locale/en.po
|
@ -26,6 +26,18 @@ msgctxt "selection:party.configuration,identifier_types:"
|
||||||
msgid "X-Rechnung Route-ID"
|
msgid "X-Rechnung Route-ID"
|
||||||
msgstr "X-Rechnung Route-ID"
|
msgstr "X-Rechnung Route-ID"
|
||||||
|
|
||||||
|
msgctxt "view:party.party:"
|
||||||
|
msgid "X-Rechnung"
|
||||||
|
msgstr "X-Rechnung"
|
||||||
|
|
||||||
|
msgctxt "field:party.party,xrechnung_routeid:"
|
||||||
|
msgid "X-Rechnung Route-ID"
|
||||||
|
msgstr "X-Rechnung Route-ID"
|
||||||
|
|
||||||
|
msgctxt "help:party.party,xrechnung_routeid:"
|
||||||
|
msgid "Enables the need for an XRechnung route ID at the party for exporting the XRechnung."
|
||||||
|
msgstr "Enables the need for an XRechnung route ID at the party for exporting the XRechnung."
|
||||||
|
|
||||||
msgctxt "field:account.tax,xrtax_category:"
|
msgctxt "field:account.tax,xrtax_category:"
|
||||||
msgid "Tax Category"
|
msgid "Tax Category"
|
||||||
msgstr "Tax Category"
|
msgstr "Tax Category"
|
||||||
|
@ -66,3 +78,7 @@ msgctxt "selection:account.tax,xrtax_category:"
|
||||||
msgid "General indirect tax of the Canary Islands"
|
msgid "General indirect tax of the Canary Islands"
|
||||||
msgstr "General indirect tax of the Canary Islands"
|
msgstr "General indirect tax of the Canary Islands"
|
||||||
|
|
||||||
|
msgctxt "selection:account.tax,xrtax_category:"
|
||||||
|
msgid "Tax on production; services and imports in Ceuta and Melilla"
|
||||||
|
msgstr "Tax on production; services and imports in Ceuta and Melilla"
|
||||||
|
|
||||||
|
|
34
party.py
34
party.py
|
@ -6,20 +6,48 @@
|
||||||
from trytond.pool import PoolMeta
|
from trytond.pool import PoolMeta
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
|
from trytond.model import fields
|
||||||
|
|
||||||
|
|
||||||
class Party(metaclass=PoolMeta):
|
class Party(metaclass=PoolMeta):
|
||||||
__name__ = 'party.party'
|
__name__ = 'party.party'
|
||||||
|
|
||||||
|
xrechnung_routeid = fields.Boolean(
|
||||||
|
string='X-Rechnung Route-ID',
|
||||||
|
help='Enables the need for an XRechnung route ID at the party ' +
|
||||||
|
'for exporting the XRechnung.')
|
||||||
|
|
||||||
def get_xrechnung_route_id(self):
|
def get_xrechnung_route_id(self):
|
||||||
""" search for route-id at party, fire-exception if missing
|
""" search for route-id at party, fire-exception if missing
|
||||||
"""
|
"""
|
||||||
for ident in self.identifiers:
|
for ident in self.identifiers:
|
||||||
if ident.type == 'edoc_route_id':
|
if ident.type == 'edoc_route_id':
|
||||||
return ident.code
|
return ident.code
|
||||||
raise UserError(gettext(
|
|
||||||
'edocument_xrechnung.msg_missing_xrechnung_route_id',
|
if self.xrechnung_routeid:
|
||||||
partyname=self.rec_name))
|
raise UserError(gettext(
|
||||||
|
'edocument_xrechnung.msg_missing_xrechnung_route_id',
|
||||||
|
partyname=self.rec_name))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_xrechnung_routeid(cls):
|
||||||
|
""" default for needs-route-id
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: default False
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def validate(cls, records):
|
||||||
|
""" validate setup of xrechnung route id
|
||||||
|
|
||||||
|
Args:
|
||||||
|
records (list): records of party.party
|
||||||
|
"""
|
||||||
|
super(Party, cls).validate(records)
|
||||||
|
for record in records:
|
||||||
|
record.get_xrechnung_route_id()
|
||||||
|
|
||||||
# end Party
|
# end Party
|
||||||
|
|
||||||
|
|
15
party.xml
Normal file
15
party.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- # This file is part of the edocument-module for Tryton from m-ds.de.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
full copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="party_view_form">
|
||||||
|
<field name="model">party.party</field>
|
||||||
|
<field name="inherit" ref="party.party_view_form"/>
|
||||||
|
<field name="name">party_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
3
setup.py
3
setup.py
|
@ -98,7 +98,8 @@ setup(
|
||||||
'trytond.modules.%s' % MODULE: (
|
'trytond.modules.%s' % MODULE: (
|
||||||
info.get('xml', [])
|
info.get('xml', [])
|
||||||
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
||||||
'template/*/*.xml', 'versiondep.txt', 'README.rst']),
|
'template/*/*.xml', 'versiondep.txt', 'README.rst',
|
||||||
|
'tests/*/*/*/*.xsd']),
|
||||||
},
|
},
|
||||||
|
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
<cbc:CreditNoteTypeCode>${this.type_code}</cbc:CreditNoteTypeCode>
|
<cbc:CreditNoteTypeCode>${this.type_code}</cbc:CreditNoteTypeCode>
|
||||||
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
||||||
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
||||||
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id()}</cbc:BuyerReference>
|
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id() or ''}</cbc:BuyerReference>
|
||||||
<cac:OrderReference py:if="this.invoice.reference">
|
<cac:OrderReference py:if="this.invoice.reference">
|
||||||
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
||||||
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
<cbc:InvoiceTypeCode>${this.type_code}</cbc:InvoiceTypeCode>
|
<cbc:InvoiceTypeCode>${this.type_code}</cbc:InvoiceTypeCode>
|
||||||
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
||||||
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
||||||
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id()}</cbc:BuyerReference>
|
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id() or ''}</cbc:BuyerReference>
|
||||||
<cac:OrderReference py:if="this.invoice.reference">
|
<cac:OrderReference py:if="this.invoice.reference">
|
||||||
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
||||||
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
<cbc:CreditNoteTypeCode>${this.type_code}</cbc:CreditNoteTypeCode>
|
<cbc:CreditNoteTypeCode>${this.type_code}</cbc:CreditNoteTypeCode>
|
||||||
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
||||||
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
||||||
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id()}</cbc:BuyerReference>
|
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id() or ''}</cbc:BuyerReference>
|
||||||
<cac:OrderReference py:if="this.invoice.reference">
|
<cac:OrderReference py:if="this.invoice.reference">
|
||||||
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
||||||
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
<cbc:InvoiceTypeCode>${this.type_code}</cbc:InvoiceTypeCode>
|
<cbc:InvoiceTypeCode>${this.type_code}</cbc:InvoiceTypeCode>
|
||||||
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
||||||
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
||||||
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id()}</cbc:BuyerReference>
|
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id() or ''}</cbc:BuyerReference>
|
||||||
<cac:OrderReference py:if="this.invoice.reference">
|
<cac:OrderReference py:if="this.invoice.reference">
|
||||||
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
||||||
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
<cbc:CreditNoteTypeCode>${this.type_code}</cbc:CreditNoteTypeCode>
|
<cbc:CreditNoteTypeCode>${this.type_code}</cbc:CreditNoteTypeCode>
|
||||||
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
||||||
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
||||||
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id()}</cbc:BuyerReference>
|
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id() or ''}</cbc:BuyerReference>
|
||||||
<cac:OrderReference py:if="this.invoice.reference">
|
<cac:OrderReference py:if="this.invoice.reference">
|
||||||
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
||||||
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
<cbc:InvoiceTypeCode>${this.type_code}</cbc:InvoiceTypeCode>
|
<cbc:InvoiceTypeCode>${this.type_code}</cbc:InvoiceTypeCode>
|
||||||
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
<cbc:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
|
||||||
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
||||||
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id()}</cbc:BuyerReference>
|
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id() or ''}</cbc:BuyerReference>
|
||||||
<cac:OrderReference py:if="this.invoice.reference">
|
<cac:OrderReference py:if="this.invoice.reference">
|
||||||
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
<cbc:ID>${this.invoice.reference}</cbc:ID>
|
||||||
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
|
||||||
|
|
|
@ -11,6 +11,7 @@ from datetime import date
|
||||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.modules.edocument_uncefact.tests.test_edocument_uncefact import get_invoice
|
from trytond.modules.edocument_uncefact.tests.test_edocument_uncefact import get_invoice
|
||||||
|
from trytond.exceptions import UserError
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
|
@ -19,6 +20,34 @@ class EdocTestCase(ModuleTestCase):
|
||||||
'Test e-rechnung module'
|
'Test e-rechnung module'
|
||||||
module = 'edocument_xrechnung'
|
module = 'edocument_xrechnung'
|
||||||
|
|
||||||
|
@with_transaction()
|
||||||
|
def test_xrechn_check_validator(self):
|
||||||
|
""" check validation of optional route-id
|
||||||
|
"""
|
||||||
|
Party = Pool().get('party.party')
|
||||||
|
|
||||||
|
party, = Party.create([{'name': 'P1'}])
|
||||||
|
self.assertEqual(party.xrechnung_routeid, False)
|
||||||
|
|
||||||
|
Party.write(*[
|
||||||
|
[party],
|
||||||
|
{
|
||||||
|
'xrechnung_routeid': True,
|
||||||
|
'identifiers': [('create', [{
|
||||||
|
'type': 'edoc_route_id',
|
||||||
|
'code': '1234'}])]}])
|
||||||
|
self.assertEqual(party.xrechnung_routeid, True)
|
||||||
|
self.assertEqual(party.get_xrechnung_route_id(), '1234')
|
||||||
|
|
||||||
|
self.assertRaisesRegex(
|
||||||
|
UserError,
|
||||||
|
"No XRechnung routing ID is stored for the party 'P1'.",
|
||||||
|
Party.write,
|
||||||
|
*[
|
||||||
|
[party],
|
||||||
|
{'identifiers': [('delete', [party.identifiers[0].id])]}]
|
||||||
|
)
|
||||||
|
|
||||||
@with_transaction()
|
@with_transaction()
|
||||||
def test_xrechn_export_xml_invoice(self):
|
def test_xrechn_export_xml_invoice(self):
|
||||||
""" run export - invoice
|
""" run export - invoice
|
||||||
|
|
|
@ -7,3 +7,4 @@ depends:
|
||||||
account_invoice
|
account_invoice
|
||||||
xml:
|
xml:
|
||||||
message.xml
|
message.xml
|
||||||
|
party.xml
|
||||||
|
|
16
view/party_form.xml
Normal file
16
view/party_form.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- # This file is part of the edocument-module for Tryton from m-ds.de.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
full copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<xpath expr="/form/notebook/page[@id='accounting']/separator[@id='account']"
|
||||||
|
position="before">
|
||||||
|
|
||||||
|
<separator string="X-Rechnung" colspan="4" id="xrechnung_routeid"/>
|
||||||
|
<label name="xrechnung_routeid"/>
|
||||||
|
<field name="xrechnung_routeid"/>
|
||||||
|
<newline/>
|
||||||
|
|
||||||
|
</xpath>
|
||||||
|
</data>
|
Loading…
Reference in a new issue