From 75a7db6441ed9ea8d4dba9527246bb5de3244927 Mon Sep 17 00:00:00 2001 From: James Jesudason Date: Mon, 9 Jan 2012 16:49:49 +0000 Subject: [PATCH] Ensure that the address is supplied for transactions. Strip invalid accented characters. --- account_banking_uk_hsbc/wizard/export_hsbc.py | 3 +++ account_banking_uk_hsbc/wizard/paymul.py | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/account_banking_uk_hsbc/wizard/export_hsbc.py b/account_banking_uk_hsbc/wizard/export_hsbc.py index 50f12de9c..eb252ca94 100644 --- a/account_banking_uk_hsbc/wizard/export_hsbc.py +++ b/account_banking_uk_hsbc/wizard/export_hsbc.py @@ -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)), diff --git a/account_banking_uk_hsbc/wizard/paymul.py b/account_banking_uk_hsbc/wizard/paymul.py index 558507b71..599a615e4 100644 --- a/account_banking_uk_hsbc/wizard/paymul.py +++ b/account_banking_uk_hsbc/wizard/paymul.py @@ -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 +