Ensure that the address is supplied for transactions. Strip invalid accented characters.

This commit is contained in:
James Jesudason
2012-01-09 16:49:49 +00:00
parent e98a61096d
commit 75a7db6441
2 changed files with 9 additions and 1 deletions

View File

@@ -230,6 +230,9 @@ class banking_export_hsbc_wizard(osv.osv_memory):
if means is None:
raise osv.except_osv('Error', "Invalid payment type mode for HSBC '%s'" % line.order_id.mode.type.name)
if not line.info_partner:
raise osv.except_osv('Error', "No default address for transaction '%s'" % line.name)
try:
return paymul.Transaction(
amount=Decimal(str(line.amount_currency)),

View File

@@ -23,6 +23,10 @@ from account_banking import sepa
from decimal import Decimal
import datetime
import re
import unicodedata
def strip_accents(string):
return unicodedata.normalize('NFKD', unicode(string)).encode('ASCII', 'ignore')
def split_account_holder(holder):
holder_parts = holder.split("\n")
@@ -79,7 +83,7 @@ class LogicalSection(object):
segments = self.segments()
def format_segment(segment):
return '+'.join([':'.join([str(y) for y in x]) for x in segment]) + "'"
return '+'.join([':'.join([str(strip_accents(y)) for y in x]) for x in segment]) + "'"
return "\n".join([format_segment(s) for s in segments])
@@ -574,3 +578,4 @@ class Transaction(LogicalSection, HasCurrency):
segments.append(nad_segment)
return segments