From be4f90e0745595894e9732a2245cfbd0ab1dfca2 Mon Sep 17 00:00:00 2001 From: hieu Date: Mon, 20 Jun 2022 15:48:34 +0700 Subject: [PATCH 1/2] [MIG] purchase: add mig script --- docsource/modules140-150.rst | 2 +- .../purchase/15.0.1.2/post-migration.py | 16 ++++++++++ .../purchase/15.0.1.2/pre-migration.py | 14 +++++++++ .../15.0.1.2/upgrade_analysis_work.txt | 31 +++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/purchase/15.0.1.2/post-migration.py create mode 100644 openupgrade_scripts/scripts/purchase/15.0.1.2/pre-migration.py create mode 100644 openupgrade_scripts/scripts/purchase/15.0.1.2/upgrade_analysis_work.txt diff --git a/docsource/modules140-150.rst b/docsource/modules140-150.rst index 8f08abc6fc63..7445847e9b1a 100644 --- a/docsource/modules140-150.rst +++ b/docsource/modules140-150.rst @@ -626,7 +626,7 @@ Module coverage 14.0 -> 15.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | project_timesheet_holidays | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| purchase | | | +| purchase | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ | purchase_mrp | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/purchase/15.0.1.2/post-migration.py b/openupgrade_scripts/scripts/purchase/15.0.1.2/post-migration.py new file mode 100644 index 000000000000..07b94b8d5865 --- /dev/null +++ b/openupgrade_scripts/scripts/purchase/15.0.1.2/post-migration.py @@ -0,0 +1,16 @@ +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.load_data(env.cr, "purchase", "15.0.1.2/noupdate_changes.xml") + openupgrade.delete_record_translations( + env.cr, + "purchase", + [ + "email_template_edi_purchase", + "email_template_edi_purchase_done", + "email_template_edi_purchase_reminder", + ], + ) + openupgrade.convert_field_to_html(env.cr, "purchase_order", "notes", "notes") diff --git a/openupgrade_scripts/scripts/purchase/15.0.1.2/pre-migration.py b/openupgrade_scripts/scripts/purchase/15.0.1.2/pre-migration.py new file mode 100644 index 000000000000..59acbf27af3d --- /dev/null +++ b/openupgrade_scripts/scripts/purchase/15.0.1.2/pre-migration.py @@ -0,0 +1,14 @@ +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.set_xml_ids_noupdate_value( + env, + "purchase", + [ + "track_po_line_qty_received_template", + "track_po_line_template", + ], + True, + ) diff --git a/openupgrade_scripts/scripts/purchase/15.0.1.2/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/purchase/15.0.1.2/upgrade_analysis_work.txt new file mode 100644 index 000000000000..0e3301555786 --- /dev/null +++ b/openupgrade_scripts/scripts/purchase/15.0.1.2/upgrade_analysis_work.txt @@ -0,0 +1,31 @@ +---Models in module 'purchase'--- +---Fields in module 'purchase'--- +purchase / product.packaging / purchase (boolean) : NEW hasdefault +# NOTHING TO DO: new feature + +purchase / purchase.order / notes (text) : type is now 'html' ('text') +# DONE: pre-migration: convert plaintext to html + +purchase / purchase.order.line / product_packaging_id (many2one): NEW relation: product.packaging +purchase / purchase.order.line / product_packaging_qty (float) : NEW +# NOTHING TO DO: new feature + +---XML records in module 'purchase'--- +NEW ir.actions.act_window: purchase.action_accrued_expense_entry +NEW ir.ui.menu: purchase.purchase_report_main +NEW ir.ui.view: purchase.account_analytic_account_view_form_purchase +NEW ir.ui.view: purchase.portal_my_purchase_rfqs +NEW ir.ui.view: purchase.product_packaging_form_view_purchase +NEW ir.ui.view: purchase.product_packaging_tree_view_purchase +NEW ir.ui.view: purchase.purchase_order_portal_content +NEW ir.ui.view: purchase.purchase_order_portal_content_totals_table +NEW ir.ui.view: purchase.purchase_report_view_tree +# NOTHING TO DO + +ir.ui.view: purchase.track_po_line_qty_received_template (noupdate) (noupdate switched) +ir.ui.view: purchase.track_po_line_template (noupdate) (noupdate switched) +# DONE: pre-migration: change noupdate to "1" + +DEL ir.ui.view: purchase.assets_backend +DEL ir.ui.view: purchase.assets_frontend + # NOTHING TO DO From c1414a7af41c43a0d7a4f5b6f787fdf42bcd86ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Thu, 11 Aug 2022 13:34:12 +0200 Subject: [PATCH 2/2] [FIX] purchase: finish migration --- .../purchase/15.0.1.2/end-migration.py | 14 +++++++++++++ .../purchase/15.0.1.2/post-migration.py | 8 ++++++- .../purchase/15.0.1.2/pre-migration.py | 21 +++++++++++++++++++ .../15.0.1.2/upgrade_analysis_work.txt | 6 +++--- 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 openupgrade_scripts/scripts/purchase/15.0.1.2/end-migration.py diff --git a/openupgrade_scripts/scripts/purchase/15.0.1.2/end-migration.py b/openupgrade_scripts/scripts/purchase/15.0.1.2/end-migration.py new file mode 100644 index 000000000000..4facc69092a3 --- /dev/null +++ b/openupgrade_scripts/scripts/purchase/15.0.1.2/end-migration.py @@ -0,0 +1,14 @@ +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + all_purchase_order_lines = env["purchase.order.line"].search( + [ + ("product_packaging_id", "!=", False), + ("state", "in", ["draft", "sent", "to approve"]), + ] + ) + for line in all_purchase_order_lines: + line._onchange_suggest_packaging() + line._onchange_update_product_packaging_qty() diff --git a/openupgrade_scripts/scripts/purchase/15.0.1.2/post-migration.py b/openupgrade_scripts/scripts/purchase/15.0.1.2/post-migration.py index 07b94b8d5865..0be4d41bdc82 100644 --- a/openupgrade_scripts/scripts/purchase/15.0.1.2/post-migration.py +++ b/openupgrade_scripts/scripts/purchase/15.0.1.2/post-migration.py @@ -3,6 +3,13 @@ @openupgrade.migrate() def migrate(env, version): + openupgrade.convert_field_to_html( + env.cr, + "purchase_order", + openupgrade.get_legacy_name("notes"), + "notes", + verbose=False, + ) openupgrade.load_data(env.cr, "purchase", "15.0.1.2/noupdate_changes.xml") openupgrade.delete_record_translations( env.cr, @@ -13,4 +20,3 @@ def migrate(env, version): "email_template_edi_purchase_reminder", ], ) - openupgrade.convert_field_to_html(env.cr, "purchase_order", "notes", "notes") diff --git a/openupgrade_scripts/scripts/purchase/15.0.1.2/pre-migration.py b/openupgrade_scripts/scripts/purchase/15.0.1.2/pre-migration.py index 59acbf27af3d..6d56f67d19c1 100644 --- a/openupgrade_scripts/scripts/purchase/15.0.1.2/pre-migration.py +++ b/openupgrade_scripts/scripts/purchase/15.0.1.2/pre-migration.py @@ -1,8 +1,15 @@ from openupgradelib import openupgrade +_columns_copy = { + "purchase_order": [ + ("notes", None, None), + ], +} + @openupgrade.migrate() def migrate(env, version): + openupgrade.copy_columns(env.cr, _columns_copy) openupgrade.set_xml_ids_noupdate_value( env, "purchase", @@ -12,3 +19,17 @@ def migrate(env, version): ], True, ) + openupgrade.add_fields( + env, + [ + ( + "purchase", + "product.packaging", + "product_packaging", + "boolean", + "bool", + "purchase", + True, + ) + ], + ) diff --git a/openupgrade_scripts/scripts/purchase/15.0.1.2/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/purchase/15.0.1.2/upgrade_analysis_work.txt index 0e3301555786..4f22010f8ad4 100644 --- a/openupgrade_scripts/scripts/purchase/15.0.1.2/upgrade_analysis_work.txt +++ b/openupgrade_scripts/scripts/purchase/15.0.1.2/upgrade_analysis_work.txt @@ -1,14 +1,14 @@ ---Models in module 'purchase'--- ---Fields in module 'purchase'--- purchase / product.packaging / purchase (boolean) : NEW hasdefault -# NOTHING TO DO: new feature +# DONE: pre-migration: fast filled with True value purchase / purchase.order / notes (text) : type is now 'html' ('text') -# DONE: pre-migration: convert plaintext to html +# DONE: post-migration: convert plaintext to html purchase / purchase.order.line / product_packaging_id (many2one): NEW relation: product.packaging purchase / purchase.order.line / product_packaging_qty (float) : NEW -# NOTHING TO DO: new feature +# DONE: end-migration: filled product_packaging_id ---XML records in module 'purchase'--- NEW ir.actions.act_window: purchase.action_accrued_expense_entry