allow route-id to be optional
This commit is contained in:
parent
004f35ad13
commit
61cf85eb0b
14 changed files with 132 additions and 10 deletions
34
party.py
34
party.py
|
@ -6,20 +6,48 @@
|
|||
from trytond.pool import PoolMeta
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import fields
|
||||
|
||||
|
||||
class Party(metaclass=PoolMeta):
|
||||
__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):
|
||||
""" search for route-id at party, fire-exception if missing
|
||||
"""
|
||||
for ident in self.identifiers:
|
||||
if ident.type == 'edoc_route_id':
|
||||
return ident.code
|
||||
raise UserError(gettext(
|
||||
'edocument_xrechnung.msg_missing_xrechnung_route_id',
|
||||
partyname=self.rec_name))
|
||||
|
||||
if self.xrechnung_routeid:
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue