Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][MIG] sale: migration script #3516

Merged
merged 2 commits into from
Jan 13, 2023
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
2 changes: 1 addition & 1 deletion docsource/modules140-150.rst
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ Module coverage 14.0 -> 15.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| resource |Nothing to do | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale | | |
| sale | Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale_coupon | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
11 changes: 11 additions & 0 deletions openupgrade_scripts/scripts/sale/15.0.1.2/end-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
all_sale_order_lines = env["sale.order.line"].search(
[("product_packaging_id", "!=", False), ("state", "in", ["draft", "sent"])]
)
for line in all_sale_order_lines:
line._onchange_suggest_packaging()
line._onchange_update_product_packaging_qty()
17 changes: 17 additions & 0 deletions openupgrade_scripts/scripts/sale/15.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.convert_field_to_html(
env.cr, "sale_order", openupgrade.get_legacy_name("note"), "note", verbose=False
)
openupgrade.load_data(env.cr, "sale", "15.0.1.2/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr,
"sale",
[
"email_template_edi_sale",
"mail_template_sale_confirmation",
],
)
38 changes: 38 additions & 0 deletions openupgrade_scripts/scripts/sale/15.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from openupgradelib import openupgrade

_columns_copy = {
"sale_order": [
("note", None, None),
],
}


@openupgrade.migrate()
def migrate(env, version):
openupgrade.copy_columns(env.cr, _columns_copy)
if openupgrade.column_exists(env.cr, "sale_order_line", "product_packaging"):
openupgrade.rename_fields(
env,
[
(
"sale.order.line",
"sale_order_line",
"product_packaging",
"product_packaging_id",
)
],
)
openupgrade.add_fields(
env,
[
(
"sales",
"product.packaging",
"product_packaging",
"boolean",
"bool",
"sale",
True,
)
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---Models in module 'sale'---
---Fields in module 'sale'---
sale / product.packaging / sales (boolean) : NEW hasdefault
# DONE: pre-migration: fast filled with True value

sale / sale.order / note (text) : type is now 'html' ('text')
# DONE: post-migration: convert text to html

sale / sale.order.line / product_packaging_id (many2one): NEW relation: product.packaging, hasdefault
sale / sale.order.line / product_packaging_qty (float) : NEW
# DONE: pre-migration: renamed from product_packaging (from sale_stock)
# DONE: end-migration: filled product_packaging_id

---XML records in module 'sale'---
NEW ir.actions.act_window: sale.action_accrued_revenue_entry
NEW ir.actions.act_window: sale.action_sale_order_form_view
NEW ir.cron: sale.send_invoice_cron (noupdate)
DEL ir.model.access: sale.access_product_group_res_partner_sale_manager
NEW ir.ui.view: sale.account_invoice_report_view_tree
NEW ir.ui.view: sale.badge_extra_price
NEW ir.ui.view: sale.crm_team_view_kanban_dashboard
NEW ir.ui.view: sale.payment_checkout_inherit
NEW ir.ui.view: sale.payment_manage_inherit
NEW ir.ui.view: sale.product_packaging_form_view_sale
NEW ir.ui.view: sale.product_packaging_tree_view_sale
NEW ir.ui.view: sale.sale_report_view_tree
DEL ir.ui.view: sale.assets_backend_inherit_sale
DEL ir.ui.view: sale.assets_frontend_inherit_sale
DEL ir.ui.view: sale.assets_tests
DEL ir.ui.view: sale.crm_team_salesteams_view_kanban
DEL ir.ui.view: sale.qunit_suite
DEL ir.ui.view: sale.report_assets_common_inherit_sale
# NOTHING TO DO: noupdate="0" records