diff --git a/openupgrade_scripts/scripts/account/16.0.1.2/pre-migration.py b/openupgrade_scripts/scripts/account/16.0.1.2/pre-migration.py index a479f8a4aa0a..5f664e50b9cb 100644 --- a/openupgrade_scripts/scripts/account/16.0.1.2/pre-migration.py +++ b/openupgrade_scripts/scripts/account/16.0.1.2/pre-migration.py @@ -549,13 +549,6 @@ def _dynamic_fast_fill_analytic_distribution_when_inherit_analytic_mixin( GROUP BY {table_name}.id """ - if is_having_analytic_account_id_col: - select_query += f""" - , {table_name}.analytic_account_id AS account_analytic_account - """ - groupby_query += f""" - , {table_name}.analytic_account_id - """ openupgrade.logged_query( env.cr, f""" @@ -603,6 +596,18 @@ def _dynamic_fast_fill_analytic_distribution_when_inherit_analytic_mixin( WHERE {table_name}.id = analytic_distribution_sub.id """, ) + if is_having_analytic_account_id_col: + openupgrade.logged_query( + env.cr, + """ + UPDATE {} + SET analytic_distribution = + analytic_distribution || jsonb_build_object({}::text, 100) + WHERE analytic_account_id IS NOT NULL + """.format( + table_name, table_name + ".analytic_account_id" + ), + ) @openupgrade.migrate()