diff --git a/docsource/modules170-180.rst b/docsource/modules170-180.rst index ce3dbd749fc3..0d251539a497 100644 --- a/docsource/modules170-180.rst +++ b/docsource/modules170-180.rst @@ -708,7 +708,7 @@ Module coverage 17.0 -> 18.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | microsoft_outlook | |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| mrp | | | +| mrp |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | mrp_account | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/mrp/18.0.2.0/post-migration.py b/openupgrade_scripts/scripts/mrp/18.0.2.0/post-migration.py new file mode 100644 index 000000000000..5f6fba7963fd --- /dev/null +++ b/openupgrade_scripts/scripts/mrp/18.0.2.0/post-migration.py @@ -0,0 +1,31 @@ +# Copyright 2025 Hunki Enterprises BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + + +def mrp_document_to_product_document(env): + """ + mrp.document has been replaced by product.document. + copy all records of mrp_document to product_document, keep a link + """ + link_column = openupgrade.get_legacy_name("mrp_document_id") + openupgrade.add_columns( + env, + [("product.document", link_column, "integer")], + ) + openupgrade.logged_query( + env.cr, + f""" + INSERT INTO product_document + (ir_attachment_id, active, sequence, {link_column}) + SELECT + ir_attachment_id, active, 10-COALESCE(priority, '0')::int, id + FROM mrp_document + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + mrp_document_to_product_document(env) diff --git a/openupgrade_scripts/scripts/mrp/18.0.2.0/pre-migration.py b/openupgrade_scripts/scripts/mrp/18.0.2.0/pre-migration.py new file mode 100644 index 000000000000..97d88a9f4618 --- /dev/null +++ b/openupgrade_scripts/scripts/mrp/18.0.2.0/pre-migration.py @@ -0,0 +1,36 @@ +# Copyright 2025 Hunki Enterprises BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + +add_columns = [ + ("product.document", "attached_on_mrp", "char", "hidden"), +] + +copy_columns = { + "mrp_production": [ + ("location_dest_id", "location_final_id", "integer"), + ], +} + + +def mrp_workorder_sequence(env): + """ + Precreate sequence field and fill with operation_id.sequence or 100 + """ + openupgrade.add_columns(env, [("mrp.workorder", "sequence", "integer", 100)]) + env.cr.execute( + """ + UPDATE mrp_workorder + SET sequence=COALESCE(mrp_routing_workcenter.sequence, mrp_workorder.sequence) + FROM mrp_routing_workcenter + WHERE mrp_workorder.operation_id=mrp_routing_workcenter.id + """ + ) + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.add_columns(env, add_columns) + openupgrade.copy_columns(env.cr, copy_columns) + mrp_workorder_sequence(env) diff --git a/openupgrade_scripts/scripts/mrp/18.0.2.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/mrp/18.0.2.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..dac52a55cb30 --- /dev/null +++ b/openupgrade_scripts/scripts/mrp/18.0.2.0/upgrade_analysis_work.txt @@ -0,0 +1,103 @@ +---Models in module 'mrp'--- +obsolete model mrp.document (merged to product.document) + +# DONE: copy records from mrp_document to product_document + +new model mrp.batch.produce [transient] + +# NOTHING TO DO + +---Fields in module 'mrp'--- +mrp / mrp.document / _inherits : DEL _inherits: {'ir.attachment': 'ir_attachment_id'}, stored: False +mrp / mrp.document / active (boolean) : DEL +mrp / mrp.document / ir_attachment_id (many2one) : DEL relation: ir.attachment, required +mrp / mrp.document / priority (selection) : DEL selection_keys: ['0', '1', '2', '3'] + +# DONE: see above + +mrp / mrp.production / location_final_id (many2one) : NEW relation: stock.location + +# DONE: copy from location_dest_id + +mrp / mrp.production / never_product_template_attribute_value_ids (many2many): NEW relation: product.template.attribute.value + +# NOTHING TO DO: new feature + +mrp / mrp.production / search_date_category (selection): NEW selection_keys: ['after', 'before', 'day_1', 'day_2', 'today', 'yesterday'], stored: False + +# NOTHING TO DO: virtual search field + +mrp / mrp.routing.workcenter / activity_ids (one2many) : NEW relation: mail.activity +mrp / mrp.routing.workcenter / message_follower_ids (one2many): NEW relation: mail.followers +mrp / mrp.routing.workcenter / message_ids (one2many) : NEW relation: mail.message +mrp / mrp.routing.workcenter / rating_ids (one2many) : NEW relation: rating.rating +mrp / mrp.routing.workcenter / website_message_ids (one2many): NEW relation: mail.message + +# NOTHING TO DO: mail/activity mixin added, new feature + +mrp / mrp.unbuild / bom_id (many2one) : now a function +mrp / mrp.unbuild / lot_id (many2one) : now a function + +# NOTHING TO DO: function are defaults + +mrp / mrp.workcenter / message_follower_ids (one2many): NEW relation: mail.followers +mrp / mrp.workcenter / message_ids (one2many) : NEW relation: mail.message +mrp / mrp.workcenter / rating_ids (one2many) : NEW relation: rating.rating +mrp / mrp.workcenter / website_message_ids (one2many): NEW relation: mail.message + +# NOTHING TO DO: mail mixin added, new feature + +mrp / mrp.workorder / _order : _order is now 'sequence, leave_id, date_start, id' ('leave_id, date_start, id') + +# DONE: set from operation_id.sequence + +mrp / mrp.workorder / production_date (datetime) : not related anymore +mrp / mrp.workorder / production_date (datetime) : now a function + +# NOTHING TO DO + +mrp / mrp.workorder / sequence (integer) : NEW hasdefault: default + +# DONE: see above + +mrp / product.document / attached_on_mrp (selection) : NEW required, selection_keys: ['bom', 'hidden'], hasdefault: default + +# NOTHING TO DO: we can't detect if a document has been attached via the bom or the product itself, so we keep the default 'hidden' + +mrp / stock.move / manual_consumption (boolean) : not a function anymore + +# NOTHING TO DO: can be edited manually now + +mrp / stock.picking.type / use_auto_consume_components_lots (boolean): DEL + +# NOTHING TO DO: replaced by manual_consumption being manually editable above + +---XML records in module 'mrp'--- +NEW ir.actions.act_window: mrp.action_mrp_batch_produce +NEW ir.actions.act_window: mrp.action_picking_tree_mrp_operation_graph +DEL ir.actions.act_window: mrp.act_assign_serial_numbers_production +NEW ir.actions.server: mrp.action_pause_workorders +NEW ir.actions.server: mrp.action_print_labels +NEW ir.actions.server: mrp.action_production_order_lock_unlock +NEW ir.actions.server: mrp.action_production_order_scrap +NEW ir.actions.server: mrp.action_start_workorders +NEW ir.model.access: mrp.access_mrp_batch_produce +NEW ir.model.access: mrp.access_stock_move_mrp_user +NEW ir.ui.view: mrp.mrp_production_workorder_tree_editable_view_mo_form +NEW ir.ui.view: mrp.product_document_form +NEW ir.ui.view: mrp.product_view_search_catalog +NEW ir.ui.view: mrp.view_mrp_batch_produce_form +NEW ir.ui.view: mrp.view_mrp_stock_move_operations +NEW ir.ui.view: mrp.view_stock_rule_form +DEL ir.ui.view: mrp.mrp_workorder_view_gantt +DEL ir.ui.view: mrp.view_assign_serial_numbers_production +DEL ir.ui.view: mrp.view_document_file_kanban_mrp +DEL ir.ui.view: mrp.view_mrp_document_form +DEL ir.ui.view: mrp.workcenter_line_gantt_production +NEW mail.message.subtype: mrp.mrp_mo_in_cancelled (noupdate) +NEW mail.message.subtype: mrp.mrp_mo_in_confirmed (noupdate) +NEW mail.message.subtype: mrp.mrp_mo_in_done (noupdate) +NEW mail.message.subtype: mrp.mrp_mo_in_progress (noupdate) +NEW mail.message.subtype: mrp.mrp_mo_in_to_close (noupdate) + +# NOTHING TO DO