From bb84e77a0e4a647c12708677e1f70b8d7238b57f Mon Sep 17 00:00:00 2001 From: Jon Erik Ceberio Date: Mon, 9 Jul 2018 12:05:22 +0200 Subject: [PATCH] [IMP] contract: possible error in migration if the column does not exist --- contract/migrations/11.0.2.0.0/pre-migration.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/contract/migrations/11.0.2.0.0/pre-migration.py b/contract/migrations/11.0.2.0.0/pre-migration.py index b97bb7a0..d48abf7b 100644 --- a/contract/migrations/11.0.2.0.0/pre-migration.py +++ b/contract/migrations/11.0.2.0.0/pre-migration.py @@ -7,7 +7,12 @@ def migrate(cr, version): """Rename column for specific price for keeping backwards compatibility.""" if not version: return - cr.execute( - "ALTER TABLE account_analytic_invoice_line " - "RENAME price_unit TO specific_price" - ) + cr.execute("""SELECT column_name + FROM information_schema.columns + WHERE table_name='account_analytic_invoice_line' AND + column_name='price_unit'""") + if cr.fetchone(): + cr.execute( + "ALTER TABLE account_analytic_invoice_line " + "RENAME price_unit TO specific_price" + )