Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions openupgrade_scripts/scripts/stock/17.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,36 @@
}


def _pre_stock_picking_picking_properties(env):
"""Avoid triggering the computed method"""
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE stock_picking
ADD COLUMN IF NOT EXISTS picking_properties jsonb
""",
)


def _pre_stock_move_line_picked(env):
"""Avoid triggering the computed method"""
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE stock_move_line
ADD COLUMN IF NOT EXISTS picked boolean
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE stock_move_line
SET picked = True
WHERE state = 'done';
""",
)


def fix_move_line_quantity(env):
"""
v17 combines what used to be reserved_qty and qty_done.
Expand Down Expand Up @@ -40,4 +70,6 @@ def fix_move_line_quantity(env):
def migrate(env, version):
openupgrade.rename_fields(env, _field_renames)
openupgrade.copy_columns(env.cr, _column_copies)
_pre_stock_picking_picking_properties(env)
_pre_stock_move_line_picked(env)
fix_move_line_quantity(env)
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ stock / stock.move.line / quantity (float) : NEW ha
# DONE: pre-migration

stock / stock.move.line / picked (boolean) : NEW hasdefault: compute
# DONE: pre-migration: Pre-create the column for avoiding triggering the compute.

stock / stock.move.line / quant_id (many2one) : NEW relation: stock.quant
stock / stock.move.line / quantity_product_uom (float) : NEW isfunction: function, stored
# NOTHING TO DO
Expand All @@ -66,7 +68,11 @@ stock / stock.picking / message_main_attachment_id (many2one):
stock / stock.picking / move_ids_without_package (one2many): is now stored
stock / stock.picking / move_ids_without_package (one2many): not a function anymore
stock / stock.picking / move_line_nosuggest_ids (one2many): DEL relation: stock.move.line
# NOTHING TO DO

stock / stock.picking / picking_properties (properties): NEW hasdefault: compute
# DONE: pre-migration: Pre-create the column for avoiding triggering the compute.

stock / stock.picking / rating_ids (one2many) : NEW relation: rating.rating
stock / stock.picking / show_operations (boolean) : not a function anymore
stock / stock.picking / show_operations (boolean) : now related
Expand Down