add bank account number to xml-export
This commit is contained in:
parent
32ef5159d2
commit
6f6de9ffb4
2 changed files with 51 additions and 16 deletions
20
mixin.py
20
mixin.py
|
@ -9,6 +9,7 @@ import html
|
|||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from trytond.tools import cached_property
|
||||
from trytond.pool import Pool
|
||||
|
||||
|
||||
class EdocumentMixin(object):
|
||||
|
@ -16,6 +17,25 @@ class EdocumentMixin(object):
|
|||
"""
|
||||
__slots__ = ()
|
||||
|
||||
def company_bank_accounts(self):
|
||||
""" get leist of bank account numbers, defined in config
|
||||
|
||||
Returns:
|
||||
list: records of model bank.account.number
|
||||
"""
|
||||
Configuration = Pool().get('account.configuration')
|
||||
|
||||
result = []
|
||||
cfg1 = Configuration.get_singleton()
|
||||
if cfg1 and cfg1.edocument_bank:
|
||||
result.extend(list(cfg1.edocument_bank))
|
||||
else:
|
||||
result.extend([
|
||||
y
|
||||
for x in self.company.party.bank_accounts
|
||||
for y in x.numbers])
|
||||
return result
|
||||
|
||||
@cached_property
|
||||
def seller_trade_address(self):
|
||||
""" get address of seller, throw exception if incomplete
|
||||
|
|
|
@ -12,7 +12,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<udt:DateTimeString format="102">${value.strftime('%Y%m%d')}</udt:DateTimeString>
|
||||
</py:def>
|
||||
<py:def function="TradeParty(party, address=None, tax_identifier=None)">
|
||||
<ram:Name>${party.name}</ram:Name>
|
||||
<ram:Name>${this.quote_text(party.name)}</ram:Name>
|
||||
<ram:SpecifiedLegalOrganization>
|
||||
<py:for each="id, attrs in this.party_legal_ids(party, address)">
|
||||
<ram:ID py:attrs="attrs">${id}</ram:ID>
|
||||
|
@ -26,13 +26,13 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<py:def function="TradeAddress(address)">
|
||||
<ram:PostcodeCode py:if="address.postal_code">${address.postal_code}</ram:PostcodeCode>
|
||||
<py:with vars="lines = (address.street or '').splitlines()">
|
||||
<ram:LineOne py:if="len(lines) > 0">${lines[0]}</ram:LineOne>
|
||||
<ram:LineTwo py:if="len(lines) > 1">${lines[1]}</ram:LineTwo>
|
||||
<ram:LineThree py:if="len(lines) > 2">${lines[2]}</ram:LineThree>
|
||||
<ram:LineOne py:if="len(lines) > 0">${this.quote_text(lines[0])}</ram:LineOne>
|
||||
<ram:LineTwo py:if="len(lines) > 1">${this.quote_text(lines[1])}</ram:LineTwo>
|
||||
<ram:LineThree py:if="len(lines) > 2">${(lines[2])}</ram:LineThree>
|
||||
</py:with>
|
||||
<ram:CityName py:if="address.city">${address.city}</ram:CityName>
|
||||
<ram:CityName py:if="address.city">${(address.city)}</ram:CityName>
|
||||
<ram:CountryID py:if="address.country">${address.country.code}</ram:CountryID>
|
||||
<ram:CountrySubDivisionName py:if="address.subdivision">${address.subdivision.name}</ram:CountrySubDivisionName>
|
||||
<ram:CountrySubDivisionName py:if="address.subdivision">${this.quote_text(address.subdivision.name)}</ram:CountrySubDivisionName>
|
||||
</py:def>
|
||||
<py:def function="TradeTax(tax, amount=None, base=None)">
|
||||
<ram:ApplicableTradeTax>
|
||||
|
@ -50,8 +50,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
</ram:GuidelineSpecifiedDocumentContextParameter>
|
||||
</rsm:ExchangedDocumentContext>
|
||||
<rsm:ExchangedDocument>
|
||||
<ram:ID>${this.invoice.number}</ram:ID>
|
||||
<ram:Name py:if="this.invoice.description">${this.invoice.description}</ram:Name>
|
||||
<ram:ID>${this.quote_text(this.invoice.number)}</ram:ID>
|
||||
<ram:Name py:if="this.invoice.description">${this.quote_text(this.invoice.description)}</ram:Name>
|
||||
<ram:TypeCode>${this.type_code}</ram:TypeCode>
|
||||
<ram:IssueDateTime>
|
||||
${DateTime(this.invoice.invoice_date)}
|
||||
|
@ -71,8 +71,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
</ram:AssociatedDocumentLineDocument>
|
||||
<ram:SpecifiedTradeProduct>
|
||||
<ram:ID py:if="line.product and line.product.code">${line.product.code}</ram:ID>
|
||||
<ram:Name>${line.product.name if line.product else ''}</ram:Name>
|
||||
<ram:Description py:if="line.description">${line.description}</ram:Description>
|
||||
<ram:Name>${this.quote_text(line.product.name if line.product else '')}</ram:Name>
|
||||
<ram:Description py:if="line.description">${this.quote_text(line.description)}</ram:Description>
|
||||
</ram:SpecifiedTradeProduct>
|
||||
<ram:SpecifiedLineTradeAgreement>
|
||||
<ram:NetPriceProductTradePrice>
|
||||
|
@ -99,10 +99,10 @@ this repository contains the full copyright notices and license terms. -->
|
|||
${TradeParty(this.buyer_trade_party, this.buyer_trade_address, this.buyer_trade_tax_identifier)}
|
||||
</ram:BuyerTradeParty>
|
||||
<ram:SellerOrderReferencedDocument py:if="this.invoice.type == 'in'">
|
||||
<ram:IssuerAssignedID>${this.invoice.reference}</ram:IssuerAssignedID>
|
||||
<ram:IssuerAssignedID>${this.quote_text(this.invoice.reference)}</ram:IssuerAssignedID>
|
||||
</ram:SellerOrderReferencedDocument>
|
||||
<ram:BuyerOrderReferencedDocument py:if="this.invoice.type == 'out'">
|
||||
<ram:IssuerAssignedID>${this.invoice.reference}</ram:IssuerAssignedID>
|
||||
<ram:IssuerAssignedID>${this.quote_text(this.invoice.reference)}</ram:IssuerAssignedID>
|
||||
</ram:BuyerOrderReferencedDocument>
|
||||
</ram:ApplicableHeaderTradeAgreement>
|
||||
<ram:ApplicableHeaderTradeDelivery>
|
||||
|
@ -114,11 +114,26 @@ this repository contains the full copyright notices and license terms. -->
|
|||
</ram:ShipFromTradeParty>
|
||||
</ram:ApplicableHeaderTradeDelivery>
|
||||
<ram:ApplicableHeaderTradeSettlement>
|
||||
<ram:PaymentReference>${this.payment_reference}</ram:PaymentReference>
|
||||
<ram:PaymentReference>${this.quote_text(this.payment_reference)}</ram:PaymentReference>
|
||||
<ram:InvoiceCurrencyCode>${this.invoice.currency.code}</ram:InvoiceCurrencyCode>
|
||||
<py:if test="len(this.company_bank_accounts()) == 0">
|
||||
<ram:SpecifiedTradeSettlementPaymentMeans>
|
||||
<ram:TypeCode>1</ram:TypeCode> <!-- Instrument not defined -->
|
||||
<ram:TypeCode>1</ram:TypeCode>
|
||||
</ram:SpecifiedTradeSettlementPaymentMeans>
|
||||
</py:if>
|
||||
<py:for each="banknumber in this.company_bank_accounts()">
|
||||
<ram:SpecifiedTradeSettlementPaymentMeans>
|
||||
<ram:TypeCode>30</ram:TypeCode>
|
||||
<ram:Information>Wire transfer</ram:Information>
|
||||
<ram:PayeePartyCreditorFinancialAccount>
|
||||
<ram:IBANID>${banknumber.number_compact}</ram:IBANID>
|
||||
<ram:AccountName>${this.quote_text(banknumber.account.bank.party.rec_name)}</ram:AccountName>
|
||||
</ram:PayeePartyCreditorFinancialAccount>
|
||||
<ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||
<ram:BICID>${banknumber.account.bank.bic}</ram:BICID>
|
||||
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||
</ram:SpecifiedTradeSettlementPaymentMeans>
|
||||
</py:for>
|
||||
<py:for each="tax in this.invoice.taxes">
|
||||
${TradeTax(tax.tax, tax.amount, tax.base)}
|
||||
</py:for>
|
||||
|
|
Loading…
Reference in a new issue