← Back to team overview

credativ team mailing list archive

lp:~therp-nl/openupgrade-server/6.1-lp1067874-res_currency_init_savepoint into lp:openupgrade-server

 

You have been requested to review the proposed merge of lp:~therp-nl/openupgrade-server/6.1-lp1067874-res_currency_init_savepoint into lp:openupgrade-server.

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-server/6.1-lp1067874-res_currency_init_savepoint/+merge/130208



-- 
https://code.launchpad.net/~therp-nl/openupgrade-server/6.1-lp1067874-res_currency_init_savepoint/+merge/130208
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-server/6.1-lp1067874-res_currency_init_savepoint into lp:openupgrade-server.
=== modified file 'openerp/addons/base/res/res_currency.py'
--- openerp/addons/base/res/res_currency.py	2012-02-08 22:40:31 +0000
+++ openerp/addons/base/res/res_currency.py	2012-10-17 19:57:22 +0000
@@ -91,9 +91,16 @@
         # we would allow duplicate "global" currencies (all having company_id == NULL) 
         cr.execute("""SELECT indexname FROM pg_indexes WHERE indexname = 'res_currency_unique_name_company_id_idx'""")
         if not cr.fetchone():
-            cr.execute("""CREATE UNIQUE INDEX res_currency_unique_name_company_id_idx
+            try:
+                cr.execute('SAVEPOINT index_currency');
+                cr.execute("""CREATE UNIQUE INDEX res_currency_unique_name_company_id_idx
                           ON res_currency
                           (name, (COALESCE(company_id,-1)))""")
+                cr.execute('RELEASE SAVEPOINT index_currency');
+            except Exception, e:
+                cr.execute('ROLLBACK TO SAVEPOINT index_currency');
+                import logging
+                logging.getLogger('OpenUpgrade').debug('Could not create currency unique index: %s', e)
 
     def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
         res = super(res_currency, self).read(cr, user, ids, fields, context, load)


References