check for valid address data
This commit is contained in:
parent
1e7a021eee
commit
994f9b2880
4 changed files with 80 additions and 0 deletions
12
locale/de.po
12
locale/de.po
|
@ -30,6 +30,18 @@ msgctxt "model:ir.message,text:msg_linetax_invalid_catcode"
|
||||||
msgid "Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s)."
|
msgid "Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s)."
|
||||||
msgstr "Ungültiger Kategoriecode an der Steuer '%(taxname)s' (erlaubt: %(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 #
|
# party.configuration #
|
||||||
|
|
12
locale/en.po
12
locale/en.po
|
@ -26,6 +26,18 @@ msgctxt "model:ir.message,text:msg_linetax_invalid_catcode"
|
||||||
msgid "Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s)."
|
msgid "Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s)."
|
||||||
msgstr "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:"
|
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"
|
||||||
|
|
|
@ -23,6 +23,15 @@ full copyright notices and license terms. -->
|
||||||
<record model="ir.message" id="msg_linetax_invalid_catcode">
|
<record model="ir.message" id="msg_linetax_invalid_catcode">
|
||||||
<field name="text">Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s).</field>
|
<field name="text">Invalid category code at tax '%(taxname)s' (allowed: %(allowed)s).</field>
|
||||||
</record>
|
</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>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
47
mixin.py
47
mixin.py
|
@ -8,6 +8,7 @@ from decimal import Decimal
|
||||||
import html
|
import html
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
|
from trytond.tools import cached_property
|
||||||
|
|
||||||
|
|
||||||
class EdocumentMixin(object):
|
class EdocumentMixin(object):
|
||||||
|
@ -15,6 +16,52 @@ class EdocumentMixin(object):
|
||||||
"""
|
"""
|
||||||
__slots__ = ()
|
__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):
|
def get_list_of_comments(self):
|
||||||
""" comment, to export in <ram:IncludedNote/>
|
""" comment, to export in <ram:IncludedNote/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue