Skip to content

Commit

Permalink
[DONTMERGE/MIG] Client-specific migration
Browse files Browse the repository at this point in the history
For the client in question, we do not need to handle analytic tags,
so this migration can be very straightforward.
  • Loading branch information
aisopuro committed May 2, 2024
1 parent 69011c1 commit 0b4c9ac
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions stock_analytic/migrations/17.0.0.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import logging

from odoo.tools import SQL, table_exists

_logger = logging.getLogger(__name__)

def migrate(cr, installed_version):
_logger.info("Migrating stock analytic data...")
need_tag_migration = (
table_exists(cr, "account_analytic_tag_stock_move_rel")
and cr.execute(
SQL(
"""
SELECT COUNT(*)
FROM account_analytic_tag_stock_move_rel
""",
),
)
and cr.fetchall()[0][0] == 0
)
assert not need_tag_migration, "analytic tag migration not implemented"
cr.execute("""
UPDATE stock_move
SET analytic_distribution = ('{"' || analytic_account_id || '": 100' || '}')::jsonb
""")
cr.execute("""
UPDATE stock_move_line
SET analytic_distribution = ('{"' || analytic_account_id || '": 100' || '}')::jsonb
""")

0 comments on commit 0b4c9ac

Please sign in to comment.