# -*- coding: utf-8 -*- # 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. 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='When activated an XRechnung route ID must be used ' 'for this party for X-Rechnung exports.\n' 'The route ID must be defined as identifier of type ' '"X-Rechnung Route-ID".') 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 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 class PartyConfiguration(metaclass=PoolMeta): __name__ = 'party.configuration' @classmethod def __setup__(cls): super(PartyConfiguration, cls).__setup__() cls.identifier_types.selection.append( ('edoc_route_id', 'X-Rechnung Route-ID')) # end Configuration