From a61099a19cd084c02911bee1142c47e8cddc2da5 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Mon, 2 Oct 2023 09:29:39 +0200 Subject: [PATCH] [FIX] product_packaging_dimension: post-migrate script should only apply query if column max_weight exists. This column is no longer defined in 16.0 --- .../migrations/16.0.1.1.0/post-migrate.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/product_packaging_dimension/migrations/16.0.1.1.0/post-migrate.py b/product_packaging_dimension/migrations/16.0.1.1.0/post-migrate.py index cb18cc1a59f4..09378d97a0a3 100644 --- a/product_packaging_dimension/migrations/16.0.1.1.0/post-migrate.py +++ b/product_packaging_dimension/migrations/16.0.1.1.0/post-migrate.py @@ -7,14 +7,15 @@ def _move_max_weight(env): """ Move max_weight value to weight if not defined """ - query = """ - UPDATE product_packaging - SET weight = max_weight - WHERE weight IS NULL OR weight = 0.0 - AND max_weight IS NOT NULL - AND product_id IS NOT NULL - """ - openupgrade.logged_query(env.cr, query) + if openupgrade.column_exists(env.cr, "product_packaging", "max_weight"): + query = """ + UPDATE product_packaging + SET weight = max_weight + WHERE weight IS NULL OR weight = 0.0 + AND max_weight IS NOT NULL + AND product_id IS NOT NULL + """ + openupgrade.logged_query(env.cr, query) @openupgrade.migrate()