← 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

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-server/6.1-lp1067874-res_currency_init_savepoint into lp:openupgrade-server.

Requested reviews:
  Thomas Winteler (Win-Soft) (thomi)
Related bugs:
  Bug #1067874 in OpenUpgrade Server: "6.1 Savepoints to be applied to raw SQL query in res_currency"
  https://bugs.launchpad.net/openupgrade-server/+bug/1067874

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 subscribed to branch 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)


Follow ups