2022-10-17 15:20:25 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2023-06-30 09:36:17 +00:00
|
|
|
# This file is part of the edocument-module for Tryton from m-ds.de.
|
2022-10-17 15:20:25 +00:00
|
|
|
# The COPYRIGHT file at the top level of this repository contains the
|
|
|
|
# full copyright notices and license terms.
|
|
|
|
|
|
|
|
from trytond.pool import PoolMeta
|
|
|
|
from trytond.exceptions import UserError
|
|
|
|
from trytond.i18n import gettext
|
2024-12-05 09:47:05 +00:00
|
|
|
from trytond.model import fields
|
2022-10-17 15:20:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Party(metaclass=PoolMeta):
|
|
|
|
__name__ = 'party.party'
|
|
|
|
|
2024-12-05 09:47:05 +00:00
|
|
|
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.')
|
|
|
|
|
2022-10-17 15:20:25 +00:00
|
|
|
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
|
2024-12-05 09:47:05 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
2024-12-12 08:45:12 +00:00
|
|
|
super().validate(records)
|
2024-12-05 09:47:05 +00:00
|
|
|
for record in records:
|
|
|
|
record.get_xrechnung_route_id()
|
2022-10-18 15:33:17 +00:00
|
|
|
|
2022-10-17 15:20:25 +00:00
|
|
|
# end Party
|
|
|
|
|
|
|
|
|
|
|
|
class PartyConfiguration(metaclass=PoolMeta):
|
|
|
|
__name__ = 'party.configuration'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def __setup__(cls):
|
2024-12-12 08:45:12 +00:00
|
|
|
super().__setup__()
|
2022-10-17 15:20:25 +00:00
|
|
|
cls.identifier_types.selection.append(
|
2024-11-21 13:43:35 +00:00
|
|
|
('edoc_route_id', 'X-Rechnung Route-ID'))
|
2022-10-17 15:20:25 +00:00
|
|
|
|
|
|
|
# end Configuration
|