summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorced <>2007-08-16 14:10:08 +0000
committerced <>2007-08-16 14:10:08 +0000
commitb53d1f9ce209048bfbbaa7a3fd713f2525a9a6ff (patch)
treed88632bd498580538ef6c9b41a48169eef2bb85b /doc
parent780016163b2e3839cf2d75439e0680511b452341 (diff)
Fix bad move from previous commit and now move the right portion from res_currency_rate
bzr revid: ced-09d632ef5348eed56ee7561f747d2b54a2209cab
Diffstat (limited to 'doc')
-rw-r--r--doc/migrate/4.0.0-4.2.0/pre-tiny.py30
-rw-r--r--doc/migrate/4.0.0-4.2.0/pre.py27
2 files changed, 29 insertions, 28 deletions
diff --git a/doc/migrate/4.0.0-4.2.0/pre-tiny.py b/doc/migrate/4.0.0-4.2.0/pre-tiny.py
index 0cd37882df3..cc07722c886 100644
--- a/doc/migrate/4.0.0-4.2.0/pre-tiny.py
+++ b/doc/migrate/4.0.0-4.2.0/pre-tiny.py
@@ -73,23 +73,6 @@ password = hasattr(options, 'db_password') and "password=%s" % options.db_passwo
db = psycopg.connect('%s %s %s %s %s' % (host, port, name, user, password), serialize=0)
cr = db.cursor()
-# ------------------------ #
-# change currency rounding #
-# ------------------------ #
-
-cr.execute("""SELECT c.relname,a.attname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,t.typname,CASE WHEN a.attlen=-1 THEN a.atttypmod-4 ELSE a.attlen END as size FROM pg_class c,pg_attribute a,pg_type t WHERE c.relname='res_currency' AND a.attname='rounding' AND c.oid=a.attrelid AND a.atttypid=t.oid""")
-res = cr.dictfetchall()
-if res[0]['typname'] != 'numeric':
- for line in (
- "ALTER TABLE res_currency RENAME rounding TO rounding_bak",
- "ALTER TABLE res_currency ADD rounding NUMERIC(12,6)",
- "UPDATE res_currency SET rounding = power(10, - rounding_bak)",
- "ALTER TABLE res_currency DROP rounding_bak",
- ):
- cr.execute(line)
-cr.commit()
-
-
# fix country
@@ -182,3 +165,16 @@ cr.execute('SELECT tablename FROM pg_tables WHERE tablename = \'subscription_sub
if cr.fetchall():
cr.execute('DROP TABLE subscription_subscription_history')
cr.commit()
+
+# -------------------- #
+# Change currency rate #
+# -------------------- #
+
+cr.execute('SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname = \'res_currency_rate\' AND a.attname = \'rate_old\' AND c.oid = a.attrelid')
+if not cr.fetchall():
+ cr.execute('ALTER TABLE res_currency_rate ADD rate_old NUMERIC(12,6)')
+ cr.execute('UPDATE res_currency_rate SET rate_old = rate')
+ cr.execute('UPDATE res_currency_rate SET rate = (1 / rate_old)')
+cr.commit()
+
+cr.close
diff --git a/doc/migrate/4.0.0-4.2.0/pre.py b/doc/migrate/4.0.0-4.2.0/pre.py
index 3eaf5465e35..b5dc76c1d88 100644
--- a/doc/migrate/4.0.0-4.2.0/pre.py
+++ b/doc/migrate/4.0.0-4.2.0/pre.py
@@ -73,6 +73,22 @@ password = hasattr(options, 'db_password') and "password=%s" % options.db_passwo
db = psycopg.connect('%s %s %s %s %s' % (host, port, name, user, password), serialize=0)
cr = db.cursor()
+# ------------------------ #
+# change currency rounding #
+# ------------------------ #
+
+cr.execute("""SELECT c.relname,a.attname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,t.typname,CASE WHEN a.attlen=-1 THEN a.atttypmod-4 ELSE a.attlen END as size FROM pg_class c,pg_attribute a,pg_type t WHERE c.relname='res_currency' AND a.attname='rounding' AND c.oid=a.attrelid AND a.atttypid=t.oid""")
+res = cr.dictfetchall()
+if res[0]['typname'] != 'numeric':
+ for line in (
+ "ALTER TABLE res_currency RENAME rounding TO rounding_bak",
+ "ALTER TABLE res_currency ADD rounding NUMERIC(12,6)",
+ "UPDATE res_currency SET rounding = power(10, - rounding_bak)",
+ "ALTER TABLE res_currency DROP rounding_bak",
+ ):
+ cr.execute(line)
+cr.commit()
+
# ----------------------------- #
# drop constraint on ir_ui_view #
# ----------------------------- #
@@ -155,15 +171,4 @@ if not cr.fetchall():
cr.execute('INSERT INTO ir_values (name, key, model, meta, key2, object, value) VALUES (\'tz\', \'meta\', \'res.users\', %s, \'tz\', %s, %s)', (meta,False, value))
cr.commit()
-# -------------------- #
-# Change currency rate #
-# -------------------- #
-
-cr.execute('SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname = \'res_currency_rate\' AND a.attname = \'rate_old\' AND c.oid = a.attrelid')
-if not cr.fetchall():
- cr.execute('ALTER TABLE res_currency_rate ADD rate_old NUMERIC(12,6)')
- cr.execute('UPDATE res_currency_rate SET rate_old = rate')
- cr.execute('UPDATE res_currency_rate SET rate = (1 / rate_old)')
-cr.commit()
-
cr.close