check for valid address data

This commit is contained in:
Frederik Jaeckel 2024-12-09 15:15:27 +01:00
parent 0150aead02
commit b2e2b36edd
4 changed files with 80 additions and 0 deletions

View file

@ -30,6 +30,18 @@ msgctxt "model:ir.message,text:msg_linetax_invalid_catcode"
msgid "Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s)."
msgstr "Ungültiger Kategoriecode an der Steuer '%(taxname)s' (erlaubt: %(allowed)s)."
msgctxt "model:ir.message,text:msg_no_seller_address"
msgid "There is no address for the seller party '%(sellerparty)s'."
msgstr "Für die Verkäuferpartei '%(sellerparty)s' existiert keine Adresse."
msgctxt "model:ir.message,text:msg_no_buyer_address"
msgid "There is no address for the buyer party '%(buyerparty)s'."
msgstr "Für die Käuferpartei '%(sellerparty)s' existiert keine Adresse."
msgctxt "model:ir.message,text:msg_no_address_country"
msgid "No country is specified for the address of the party '%(party)s'."
msgstr "Für die Adresse der Partei '%(party)s' ist kein Land festgelegt."
#######################
# party.configuration #

View file

@ -26,6 +26,18 @@ msgctxt "model:ir.message,text:msg_linetax_invalid_catcode"
msgid "Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s)."
msgstr "Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s)."
msgctxt "model:ir.message,text:msg_no_seller_address"
msgid "There is no address for the seller party '%(sellerparty)s'."
msgstr "There is no address for the seller party '%(sellerparty)s'."
msgctxt "model:ir.message,text:msg_no_buyer_address"
msgid "There is no address for the buyer party '%(buyerparty)s'."
msgstr "There is no address for the buyer party '%(buyerparty)s'."
msgctxt "model:ir.message,text:msg_no_address_country"
msgid "No country is specified for the address of the party '%(party)s'."
msgstr "No country is specified for the address of the party '%(party)s'."
msgctxt "selection:party.configuration,identifier_types:"
msgid "X-Rechnung Route-ID"
msgstr "X-Rechnung Route-ID"

View file

@ -23,6 +23,15 @@ full copyright notices and license terms. -->
<record model="ir.message" id="msg_linetax_invalid_catcode">
<field name="text">Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s).</field>
</record>
<record model="ir.message" id="msg_no_seller_address">
<field name="text">There is no address for the seller party '%(sellerparty)s'.</field>
</record>
<record model="ir.message" id="msg_no_buyer_address">
<field name="text">There is no address for the buyer party '%(buyerparty)s'.</field>
</record>
<record model="ir.message" id="msg_no_address_country">
<field name="text">No country is specified for the address of the party '%(party)s'.</field>
</record>
</data>
</tryton>

View file

@ -8,6 +8,7 @@ from decimal import Decimal
import html
from trytond.exceptions import UserError
from trytond.i18n import gettext
from trytond.tools import cached_property
class EdocumentMixin(object):
@ -15,6 +16,52 @@ class EdocumentMixin(object):
"""
__slots__ = ()
@cached_property
def seller_trade_address(self):
""" get address of seller, throw exception if incomplete
Raises:
UserError: if no address
UserError: if no country on address
Returns:
record : model party.address
"""
result = super(EdocumentMixin, self).seller_trade_address
if not result:
raise UserError(gettext(
'edocument_xrechnung.msg_no_seller_address',
sellerparty=self.invoice.company.rec_name
if self.invoice and self.invoice.company
else '-'))
if not result.country:
raise UserError(gettext(
'edocument_xrechnung.msg_no_address_country',
party=result.party))
return result
@cached_property
def buyer_trade_address(self):
""" exception if no address
Returns:
record: model party.address
"""
if (self.invoice.type == 'out') and (
not self.invoice.invoice_address):
raise UserError(gettext(
'edocument_xrechnung.msg_no_buyer_address',
buyerparty=self.invoice.party.rec_name
if self.invoice and self.invoice.party
else '-'))
result = super(EdocumentMixin, self).buyer_trade_address
if result and not result.country:
raise UserError(gettext(
'edocument_xrechnung.msg_no_address_country',
party=result.party))
return result
def get_list_of_comments(self):
""" comment, to export in <ram:IncludedNote/>