From 703861029a2d3a36bbb18ed9e56c55064323478c Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 4 Nov 2015 10:45:55 +0100 Subject: [PATCH] [FIX] account_banking_payment_export: Check if column exists before creating it --- .../migrations/8.0.0.1.166/pre-migrate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/account_banking_payment_export/migrations/8.0.0.1.166/pre-migrate.py b/account_banking_payment_export/migrations/8.0.0.1.166/pre-migrate.py index 97f37ffd3..870747844 100644 --- a/account_banking_payment_export/migrations/8.0.0.1.166/pre-migrate.py +++ b/account_banking_payment_export/migrations/8.0.0.1.166/pre-migrate.py @@ -20,7 +20,14 @@ def migrate(cr, version): - cr.execute('alter table payment_order add column total numeric') + cr.execute( + 'SELECT count(attname) FROM pg_attribute ' + 'WHERE attrelid = ' + '( SELECT oid FROM pg_class WHERE relname = %s ) ' + 'AND attname = %s', + ('payment_order', 'total')) + if cr.fetchone()[0] == 0: + cr.execute('alter table payment_order add column total numeric') cr.execute( 'update payment_order ' 'set total=totals.total '