diff --git a/addons/account_followup/account_followup_customers.xml b/addons/account_followup/account_followup_customers.xml
index 0471eb52fbe..8a27730b003 100644
--- a/addons/account_followup/account_followup_customers.xml
+++ b/addons/account_followup/account_followup_customers.xml
@@ -62,6 +62,7 @@
res.partner.followup.form.inheritres.partner
+
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 9456c87bbf9..ef9429b3423 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -249,7 +249,7 @@ class crm_lead(base_stage, format_address, osv.osv):
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority', select=True),
'date_closed': fields.datetime('Closed', readonly=True),
'stage_id': fields.many2one('crm.case.stage', 'Stage', track_visibility=1,
- domain="[('fold', '=', False), ('section_ids', '=', section_id), '|', ('type', '=', type), ('type', '=', 'both')]"),
+ domain="['&', '&', ('fold', '=', False), ('section_ids', '=', section_id), '|', ('type', '=', type), ('type', '=', 'both')]"),
'user_id': fields.many2one('res.users', 'Salesperson', track_visibility=1),
'referred': fields.char('Referred By', size=64),
'date_open': fields.datetime('Opened', readonly=True),
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index ce5d4555028..3ac33348509 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -100,7 +100,7 @@
states="cancel"/>
-
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index 95a64adaed6..2c156ca2ac2 100644
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -180,7 +180,7 @@
crm.case.stage
-
+
diff --git a/addons/l10n_be_coda/wizard/account_coda_import.py b/addons/l10n_be_coda/wizard/account_coda_import.py
index a72ad2e5d39..2b04cf9dc56 100644
--- a/addons/l10n_be_coda/wizard/account_coda_import.py
+++ b/addons/l10n_be_coda/wizard/account_coda_import.py
@@ -90,19 +90,30 @@ class account_coda_import(osv.osv_memory):
raise osv.except_osv(_('Error') + ' R1002', _('Foreign bank accounts with IBAN structure are not supported '))
else: # Something else, not supported
raise osv.except_osv(_('Error') + ' R1003', _('Unsupported bank account structure '))
- bank_ids = self.pool.get('res.partner.bank').search(cr, uid, [('acc_number', '=', statement['acc_number'])])
- not_found_except = osv.except_osv(_('Error') + ' R1004', _("No matching Bank Account.\n\nPlease set-up a Bank Account with as Account Number '%s' and as Currency '%s'.") % (statement['acc_number'], statement['currency']))
+ statement['journal_id'] = False
+ statement['bank_account'] = False
+ # Belgian Account Numbers are composed of 12 digits.
+ # In OpenERP, the user can fill the bank number in any format: With or without IBan code, with or without spaces, with or without '-'
+ # The two following sql requests handle those cases.
+ if len(statement['acc_number']) >= 12:
+ # If the Account Number is >= 12 digits, it is mostlikely a Belgian Account Number (With or without IBAN).
+ # The following request try to find the Account Number using a 'like' operator.
+ # So, if the Account Number is stored with IBAN code, it can be found thanks to this.
+ cr.execute("select id from res_partner_bank where replace(replace(acc_number,' ',''),'-','') like %s", ('%' + statement['acc_number'] + '%',))
+ else:
+ # This case is necessary to avoid cases like the Account Number in the CODA file is set to a single or few digits,
+ # and so a 'like' operator would return the first account number in the database which matches.
+ cr.execute("select id from res_partner_bank where replace(replace(acc_number,' ',''),'-','') = %s", (statement['acc_number'],))
+ bank_ids = [id[0] for id in cr.fetchall()]
if bank_ids and len(bank_ids) > 0:
bank_accs = self.pool.get('res.partner.bank').browse(cr, uid, bank_ids)
for bank_acc in bank_accs:
- if (bank_acc.journal_id.currency and bank_acc.journal_id.currency.name != statement['currency']) and (not bank_acc.journal_id.currency and bank_acc.journal_id.company_id.currency_id.name != statement['currency']):
- raise not_found_except
- else:
+ if not (bank_acc.journal_id and (bank_acc.journal_id.currency and bank_acc.journal_id.currency.name != statement['currency']) and (not bank_acc.journal_id.currency and bank_acc.journal_id.company_id.currency_id.name != statement['currency'])):
statement['journal_id'] = bank_acc.journal_id
statement['bank_account'] = bank_acc
break
- else:
- raise not_found_except
+ if statement['bank_account'] == False:
+ raise osv.except_osv(_('Error') + ' R1004', _("No matching Bank Account (with Account Journal) found.\n\nPlease set-up a Bank Account with as Account Number '%s' and as Currency '%s' and an Account Journal.") % (statement['acc_number'], statement['currency']))
statement['description'] = rmspaces(line[90:125])
statement['balance_start'] = float(rmspaces(line[43:58])) / 1000
statement['balance_start_date'] = time.strftime(tools.DEFAULT_SERVER_DATE_FORMAT, time.strptime(rmspaces(line[58:64]), '%d%m%y'))
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index b797001b26b..90efba013ab 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -471,8 +471,9 @@ class mail_thread(osv.AbstractModel):
# 2. Look for a matching mail.alias entry
# Delivered-To is a safe bet in most modern MTAs, but we have to fallback on To + Cc values
# for all the odd MTAs out there, as there is no standard header for the envelope's `rcpt_to` value.
- rcpt_tos = decode_header(message, 'Delivered-To') or \
- ','.join([decode_header(message, 'To'),
+ rcpt_tos = \
+ ','.join([decode_header(message, 'Delivered-To'),
+ decode_header(message, 'To'),
decode_header(message, 'Cc'),
decode_header(message, 'Resent-To'),
decode_header(message, 'Resent-Cc')])