Fix migration script as res_currency_rate was not in the 4.0
bzr revid: ced-a2eff65b19589f35fe4f2dc4c24589507a7910e6
This commit is contained in:
parent
c8b3c37100
commit
c2680d5502
|
@ -73,6 +73,23 @@ 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
|
||||
|
||||
|
||||
|
|
|
@ -73,22 +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()
|
||||
|
||||
# ----------------------------- #
|
||||
# drop constraint on ir_ui_view #
|
||||
# ----------------------------- #
|
||||
|
|
Loading…
Reference in New Issue