check for valid address data
This commit is contained in:
parent
1e7a021eee
commit
994f9b2880
4 changed files with 80 additions and 0 deletions
47
mixin.py
47
mixin.py
|
@ -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/>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue