diff --git a/docsource/modules180-190.rst b/docsource/modules180-190.rst index c92e1ccc576f..362fe8a0cd84 100644 --- a/docsource/modules180-190.rst +++ b/docsource/modules180-190.rst @@ -746,9 +746,9 @@ Module coverage 18.0 -> 19.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | microsoft_outlook | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| mrp | | | +| mrp |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| mrp_account | | | +| mrp_account |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | mrp_landed_costs | |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/mrp/19.0.2.0/post-migration.py b/openupgrade_scripts/scripts/mrp/19.0.2.0/post-migration.py new file mode 100644 index 000000000000..ddad5740b2fd --- /dev/null +++ b/openupgrade_scripts/scripts/mrp/19.0.2.0/post-migration.py @@ -0,0 +1,104 @@ +# Copyright 2026 Hunki Enterprises BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + + +def mrp_production_group(env): + """ + Create production groups from procurement groups + """ + link_column = openupgrade.get_legacy_name("procurement_group_id") + env.cr.execute( + f"ALTER TABLE mrp_production_group ADD COLUMN IF NOT EXISTS {link_column} int" + ) + env.cr.execute( + f""" + INSERT INTO mrp_production_group + (name, {link_column}) + SELECT + stock_reference.name, stock_reference.id + FROM + stock_reference + WHERE id IN ( + SELECT procurement_group_id FROM + mrp_production + ) + """ + ) + env.cr.execute( + f""" + UPDATE mrp_production + SET production_group_id=mrp_production_group.id + FROM + mrp_production_group + WHERE {link_column}=procurement_group_id + """ + ) + env.cr.execute( + f""" + UPDATE stock_move + SET production_group_id=mrp_production_group.id + FROM + mrp_production_group + WHERE {link_column}=group_id + """ + ) + + +def mrp_workorder_state(env): + """ + Map mrp.workorder#state values + """ + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("state"), + "state", + [("pending", "blocked"), ("waiting", "blocked")], + table="mrp_workorder", + ) + + +def mrp_workcenter_capacity_product_uom_id(env): + """ + Fill mrp.workcenter.capacity#product_uom_id + """ + env.cr.execute( + f""" + UPDATE mrp_workcenter_capacity + SET + product_uom_id=COALESCE( + product_template.uom_id, + {env.ref("uom.product_uom_unit").id} + ) + FROM + product_product, + product_template + WHERE + mrp_workcenter_capacity.product_id=product_product.id + AND + product_product.product_tmpl_id=product_template.id + """ + ) + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.load_data(env, "mrp", "19.0.2.0/noupdate_changes.xml") + openupgrade.m2o_to_x2m( + env.cr, + env["mrp.production"], + "mrp_production", + "lot_producing_ids", + "lot_producing_id", + ) + openupgrade.m2o_to_x2m( + env.cr, + env["mrp.production"], + "mrp_production", + "reference_ids", + "procurement_group_id", + ) + mrp_production_group(env) + mrp_workorder_state(env) + mrp_workcenter_capacity_product_uom_id(env) diff --git a/openupgrade_scripts/scripts/mrp/19.0.2.0/pre-migration.py b/openupgrade_scripts/scripts/mrp/19.0.2.0/pre-migration.py new file mode 100644 index 000000000000..bad954ee4e58 --- /dev/null +++ b/openupgrade_scripts/scripts/mrp/19.0.2.0/pre-migration.py @@ -0,0 +1,41 @@ +# Copyright 2026 Hunki Enterprises BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + +_added_fields = [ + ( + "product_uom_id", + "mrp.workcenter.capacity", + "mrp_workcenter_capacity", + "many2one", + None, + "mrp", + ) +] + +_renamed_field_references = [ + ( + "mrp.production", + "lot_producing_id", + "lot_producing_ids", + ), + ( + "mrp.production", + "procurement_group_id", + "reference_ids", + ), +] + +_copied_columns = { + "mrp_workorder": [ + ("state", None, None), + ] +} + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.add_fields(env, _added_fields) + openupgrade.rename_field_references(env, _renamed_field_references) + openupgrade.copy_columns(env.cr, _copied_columns) diff --git a/openupgrade_scripts/scripts/mrp/19.0.2.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/mrp/19.0.2.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..20b4d8a4fc92 --- /dev/null +++ b/openupgrade_scripts/scripts/mrp/19.0.2.0/upgrade_analysis_work.txt @@ -0,0 +1,145 @@ +---Models in module 'mrp'--- +obsolete model mrp.batch.produce (renamed to mrp.production.serials) [transient] + +# NOTHING TO DO + +new model mrp.production.group + +# DONE: created from procurement groups + +new model mrp.production.serials (renamed from mrp.batch.produce) [transient] + +# NOTHING TO DO + +---Fields in module 'mrp'--- +mrp / mrp.bom / batch_size (float) : NEW hasdefault: default +mrp / mrp.bom / enable_batch_size (boolean) : NEW hasdefault: default + +# NOTHING TO DO: new feature, defaults keep previous behavior + +mrp / mrp.bom.line / manual_consumption (boolean) : DEL +mrp / mrp.production / date_deadline (datetime) : not a function anymore + +# NOTHING TO DO + +mrp / mrp.production / lot_producing_id (many2one) : DEL relation: stock.lot +mrp / mrp.production / lot_producing_ids (many2many) : NEW relation: stock.lot + +# DONE: m2o_to_x2m + +mrp / mrp.production / procurement_group_id (many2one): DEL relation: procurement.group + +# DONE: m2o_to_x2m + +mrp / mrp.production / production_group_id (many2one): NEW relation: mrp.production.group + +# DONE: created from procurement_group_id in post-migration + +mrp / mrp.production / reference_ids (many2many) : NEW relation: stock.reference + +# DONE: m2o_to_x2m + +mrp / mrp.production.group / child_ids (many2many) : NEW relation: mrp.production.group +mrp / mrp.production.group / name (char) : NEW required +mrp / mrp.production.group / parent_ids (many2many) : NEW relation: mrp.production.group + +# NOTHING TO DO + +mrp / mrp.production.group / production_ids (one2many) : NEW relation: mrp.production + +# DONE: see mrp.production#production_group_id + +mrp / mrp.routing.workcenter / cost_mode (selection) : NEW selection_keys: ['actual', 'estimated'], hasdefault: default +mrp / mrp.routing.workcenter / note (html) : DEL +mrp / mrp.routing.workcenter / worksheet (binary) : DEL attachment: True +mrp / mrp.routing.workcenter / worksheet_google_slide (char) : DEL +mrp / mrp.routing.workcenter / worksheet_type (selection) : DEL selection_keys: ['google_slide', 'pdf', 'text'] +mrp / mrp.unbuild / lot_id (many2one) : not a function anymore +mrp / mrp.workcenter / default_capacity (float) : DEL + +# NOTHING TO DO + +mrp / mrp.workcenter.capacity / product_uom_id (many2one) : is now stored +mrp / mrp.workcenter.capacity / product_uom_id (many2one) : not related anymore +mrp / mrp.workcenter.capacity / product_uom_id (many2one) : now required + +# DONE: precreated and filled from product_id + +mrp / mrp.workcenter.productivity / loss_type (selection) : not stored anymore +mrp / mrp.workcenter.productivity.loss / loss_type (selection) : not stored anymore +mrp / mrp.workorder / cost_mode (selection) : NEW selection_keys: ['actual', 'estimated'], hasdefault: default + +# NOTHING TO DO + +mrp / mrp.workorder / last_working_user_id (one2many): type is now 'many2one' ('one2many') + +# NOTHING TO DO: nonstored + +mrp / mrp.workorder / product_id (many2one) : not stored anymore +mrp / mrp.workorder / product_uom_id (many2one) : not stored anymore +mrp / mrp.workorder / product_uom_id (many2one) : now related + +# NOTHING TO DO + +mrp / mrp.workorder / state (selection) : selection_keys added: [blocked], removed: [pending, waiting] + +# DONE: pending, waiting mapped to blocked + +mrp / procurement.group / mrp_production_ids (one2many) : DEL relation: mrp.production + +# DONE: see mrp.production#procurement_group_id + +mrp / res.company / manufacturing_lead (float) : DEL required +mrp / stock.move / is_done (boolean) : DEL +mrp / stock.move / order_finished_lot_id (many2one): DEL relation: stock.lot +mrp / stock.move / production_group_id (many2one): NEW relation: mrp.production.group + +# DONE: set to production group created for mrp.production#procurement_group_id + +mrp / stock.picking / production_ids (many2many) : not a function anymore +mrp / stock.picking / production_ids (many2many) : now related +mrp / stock.picking / production_ids (many2many) : type is now 'one2many' ('many2many') + +# NOTHING TO DO: set by setting stock.move#production_group_id + +mrp / stock.reference / production_ids (many2many) : NEW relation: mrp.production + +# DONE: see mrp.production#reference_ids + +mrp / stock.warehouse / manufacture_to_resupply (boolean): not stored anymore +mrp / stock.warehouse / manufacture_to_resupply (boolean): now a function +mrp / stock.warehouse.orderpoint / manufacturing_visibility_days (float): DEL + +# NOTHING TO DO + +---XML records in module 'mrp'--- +NEW ir.actions.act_window: mrp.action_assign_serial_numbers +DEL ir.actions.act_window: mrp.act_product_mrp_production_workcenter +DEL ir.actions.act_window: mrp.action_mrp_batch_produce +NEW ir.model.access: mrp.access_mrp_production_group +NEW ir.model.access: mrp.access_mrp_production_serials +DEL ir.model.access: mrp.access_mrp_batch_produce +DEL ir.model.access: mrp.access_mrp_document_mrp_user +DEL ir.model.access: mrp.access_product_category_mrp_manager +DEL ir.model.access: mrp.access_product_packaging_mrp_manager +DEL ir.model.access: mrp.access_product_pricelist_mrp_manager +DEL ir.model.access: mrp.access_product_product_mrp_manager +DEL ir.model.access: mrp.access_product_supplierinfo_user +DEL ir.model.access: mrp.access_product_tag_mrp_manager +DEL ir.model.access: mrp.access_product_template_mrp_manager +DEL ir.model.access: mrp.access_uom_category +DEL ir.model.access: mrp.access_uom_category_mrp_manager +DEL ir.model.access: mrp.access_uom_uom_mrp_manager +ir.model.constraint: mrp.constraint_mrp_workcenter_capacity_positive_capacity (changed definition: is now 'CHECK(capacity >= 0)' ('check(capacity > 0)')) +NEW ir.model.constraint: mrp.constraint_mrp_workcenter_capacity_workcenter_product_product_uom_unique +DEL ir.model.constraint: mrp.constraint_mrp_workcenter_capacity_unique_product +NEW ir.ui.view: mrp.mrp_bom_replenishment_tree_view +NEW ir.ui.view: mrp.mrp_routing_workcenter_kanban_view +NEW ir.ui.view: mrp.view_move_line_tree +NEW ir.ui.view: mrp.view_mrp_production_serials_form +NEW ir.ui.view: mrp.view_stock_replenishment_info_stock_mrp_inherit +DEL ir.ui.view: mrp.view_mrp_batch_produce_form +DEL ir.ui.view: mrp.view_stock_move_line_detailed_operation_tree_mrp +NEW res.groups.privilege: mrp.res_groups_privilege_manufacturing + +# NOTHING TO DO diff --git a/openupgrade_scripts/scripts/mrp_account/19.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/mrp_account/19.0.1.0/pre-migration.py new file mode 100644 index 000000000000..fd635c78a5c0 --- /dev/null +++ b/openupgrade_scripts/scripts/mrp_account/19.0.1.0/pre-migration.py @@ -0,0 +1,21 @@ +# Copyright 2026 Hunki Enterprises BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + +_renamed_tables = [ + ("account_move_mrp_production_rel", "wip_move_production_rel"), +] + +_renamed_columns = { + "wip_move_production_rel": [ + ("account_move_id", "move_id"), + ("mrp_production_id", "production_id"), + ] +} + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.rename_tables(env.cr, _renamed_tables) + openupgrade.rename_columns(env.cr, _renamed_columns) diff --git a/openupgrade_scripts/scripts/mrp_account/19.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/mrp_account/19.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..27ac1b0816b1 --- /dev/null +++ b/openupgrade_scripts/scripts/mrp_account/19.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,14 @@ +---Models in module 'mrp_account'--- +---Fields in module 'mrp_account'--- +mrp_account / account.move / wip_production_ids (many2many): column1 is now 'move_id' ('account_move_id') [account_move_mrp_production_rel] +mrp_account / account.move / wip_production_ids (many2many): column2 is now 'production_id' ('mrp_production_id') [account_move_mrp_production_rel] +mrp_account / account.move / wip_production_ids (many2many): table is now 'wip_move_production_rel' ('account_move_mrp_production_rel') + +# DONE: renamed in pre-migration + +mrp_account / mrp.production / wip_move_ids (many2many) : NEW relation: account.move + +# NOTHING TO DO + +---XML records in module 'mrp_account'--- +DEL ir.ui.view: mrp_account.view_category_property_form