Skip to content

Commit

Permalink
Merge pull request #3752 from Tecnativa/v15_mig_delivery_oca
Browse files Browse the repository at this point in the history
[15.0][OU-ADD] delivery: Migration scripts
  • Loading branch information
pedrobaeza authored Mar 11, 2023
2 parents 38f9175 + 8b31964 commit 62bd88d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docsource/modules140-150.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Module coverage 14.0 -> 15.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| crm_sms | Nothing to do | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| delivery | | |
| delivery | Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |new| delivery_mondialrelay | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
40 changes: 40 additions & 0 deletions openupgrade_scripts/scripts/delivery/15.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from openupgradelib import openupgrade


def _move_data_from_product_packaging_to_stock_package_type(env):
openupgrade.logged_query(
env.cr,
"""ALTER TABLE stock_package_type
ADD COLUMN IF NOT EXISTS old_product_packaging_id INTEGER""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO stock_package_type(old_product_packaging_id,
name, sequence, height, width,
shipper_package_code, package_carrier_type,
packaging_length, max_weight, barcode, company_id,
create_uid, create_date, write_uid, write_date)
SELECT id,
name, sequence, height, width,
shipper_package_code, package_carrier_type,
packaging_length, max_weight, barcode, company_id,
create_uid, create_date, write_uid, write_date
FROM product_packaging
WHERE product_id IS NULL
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE stock_quant_package sqp
SET package_type_id = spt.id
FROM stock_package_type spt
WHERE spt.old_product_packaging_id = sqp.packaging_id
""",
)


@openupgrade.migrate()
def migrate(env, version):
_move_data_from_product_packaging_to_stock_package_type(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---Models in module 'delivery'---
---Fields in module 'delivery'---
delivery / product.packaging / height (integer) : DEL
delivery / product.packaging / max_weight (float) : DEL
delivery / product.packaging / package_carrier_type (selection): DEL selection_keys: ['none']
delivery / product.packaging / packaging_length (integer) : DEL
delivery / product.packaging / shipper_package_code (char) : DEL
delivery / product.packaging / width (integer) : DEL
delivery / stock.package.type / package_carrier_type (selection): NEW selection_keys: ['none'], hasdefault
delivery / stock.package.type / shipper_package_code (char) : NEW
# DONE: post-migration: move data from product_packaging table to stock_package_type

---XML records in module 'delivery'---
DEL ir.actions.act_window: delivery.action_delivery_packaging_view
DEL ir.ui.menu: delivery.menu_delivery [renamed to stock module]
DEL ir.ui.menu: delivery.menu_delivery_packagings
NEW ir.ui.view: delivery.stock_package_type_form_delivery
NEW ir.ui.view: delivery.stock_package_type_tree_delivery
NEW ir.ui.view: delivery.view_move_line_tree_detailed_delivery
DEL ir.ui.view: delivery.product_packaging_delivery_form
DEL ir.ui.view: delivery.product_packaging_delivery_tree
DEL ir.ui.view: delivery.view_quant_package_packaging_tree
# NOTHING TO DO: noupdate="0" records

0 comments on commit 62bd88d

Please sign in to comment.