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 fce160ef4d2..0cd37882df3 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,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 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 24c38284b94..3eaf5465e35 100644 --- a/doc/migrate/4.0.0-4.2.0/pre.py +++ b/doc/migrate/4.0.0-4.2.0/pre.py @@ -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 # # ----------------------------- #