From 07ef84cf70368be13f630aaf07162951bd16c995 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Fri, 16 Mar 2007 11:38:50 +0000
Subject: [PATCH] Generate automatically reference number if after ank account
 creation it is still None.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13452 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Banking/tests/TestERP5BankingMixin.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/product/ERP5Banking/tests/TestERP5BankingMixin.py b/product/ERP5Banking/tests/TestERP5BankingMixin.py
index ea34cdecb8..e5a548ec05 100644
--- a/product/ERP5Banking/tests/TestERP5BankingMixin.py
+++ b/product/ERP5Banking/tests/TestERP5BankingMixin.py
@@ -681,6 +681,15 @@ class TestERP5BankingMixin:
                                      portal_type = 'Bank Account',
                                      price_currency_value = currency,
                                      **kw)
+    if not kw.has_key('reference') and bank_account.getReference() is None:
+      # If there is no automatic getter-time calculation of the reference and
+      # no reference has been explicitely set, generate one composed of all
+      # bank codes and a static prefix - to avoid collisions as much as
+      # possible.
+      bank_account.edit(reference='ref_%s%s%s%s%s' % (kw['bank_country_code'],
+        kw['bank_code'], kw['branch'], kw['bank_account_number'],
+        kw['bank_account_key']))
+      
     # validate this bank account for payment
     bank_account.validate()
     if amount == 0:
-- 
2.30.9