[FIX] account_banking_payment_export: Check if column exists before creating it

This commit is contained in:
Pedro M. Baeza
2015-11-04 10:45:55 +01:00
parent 58ea12ac88
commit 703861029a

View File

@@ -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 '