diff --git a/docsource/modules170-180.rst b/docsource/modules170-180.rst index ba2592918d7d..fb374d70d247 100644 --- a/docsource/modules170-180.rst +++ b/docsource/modules170-180.rst @@ -1032,7 +1032,7 @@ Module coverage 17.0 -> 18.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | stock | Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| stock_account | | | +| stock_account | Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | stock_delivery | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/stock_account/18.0.1.1/end-migration.py b/openupgrade_scripts/scripts/stock_account/18.0.1.1/end-migration.py new file mode 100644 index 000000000000..8cabe7020624 --- /dev/null +++ b/openupgrade_scripts/scripts/stock_account/18.0.1.1/end-migration.py @@ -0,0 +1,23 @@ +# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + for company in env["res.company"].search([("chart_template", "!=", False)]): + if not company.country_id.code: + continue + module_name = "l10n_" + company.country_id.code.lower() + l10n_module = env["ir.module.module"].search( + [ + ("name", "=", module_name), + ("state", "=", "installed"), + ] + ) + if not l10n_module: + continue + template_code = company.chart_template + ChartTemplate = env["account.chart.template"].with_company(company) + full_data = ChartTemplate._get_chart_template_data(template_code) + ChartTemplate._load_wip_accounts(company, full_data["res.company"]) diff --git a/openupgrade_scripts/scripts/stock_account/18.0.1.1/post-migration.py b/openupgrade_scripts/scripts/stock_account/18.0.1.1/post-migration.py new file mode 100644 index 000000000000..3aa988146876 --- /dev/null +++ b/openupgrade_scripts/scripts/stock_account/18.0.1.1/post-migration.py @@ -0,0 +1,36 @@ +# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade, openupgrade_180 + + +def convert_company_dependent(env): + openupgrade_180.convert_company_dependent( + env, "product.category", "property_cost_method" + ) + openupgrade_180.convert_company_dependent( + env, "product.category", "property_stock_account_input_categ_id" + ) + openupgrade_180.convert_company_dependent( + env, "product.category", "property_stock_account_output_categ_id" + ) + openupgrade_180.convert_company_dependent( + env, "product.category", "property_stock_journal" + ) + openupgrade_180.convert_company_dependent( + env, "product.category", "property_stock_valuation_account_id" + ) + openupgrade_180.convert_company_dependent( + env, "product.category", "property_valuation" + ) + + +@openupgrade.migrate() +def migrate(env, version): + convert_company_dependent(env) + openupgrade.delete_records_safely_by_xml_id( + env, + [ + "stock_account.default_category_cost_method", + "stock_account.default_category_valuation", + ], + ) diff --git a/openupgrade_scripts/scripts/stock_account/18.0.1.1/pre-migration.py b/openupgrade_scripts/scripts/stock_account/18.0.1.1/pre-migration.py new file mode 100644 index 000000000000..e62ed45e28d7 --- /dev/null +++ b/openupgrade_scripts/scripts/stock_account/18.0.1.1/pre-migration.py @@ -0,0 +1,22 @@ +# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + + +def delete_property_xmlids(env): + # avoid conflict in in _create_default_stock_accounts_properties + # they changed records from ir.property to ir.default + for field in [ + "property_stock_account_output_categ_id", + "property_stock_account_input_categ_id", + ]: + imd = env["ir.model.data"].search( + [("module", "=", "stock_account"), ("name", "=", field)] + ) + if imd: + imd.unlink() + + +@openupgrade.migrate() +def migrate(env, version): + delete_property_xmlids(env) diff --git a/openupgrade_scripts/scripts/stock_account/18.0.1.1/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/stock_account/18.0.1.1/upgrade_analysis_work.txt new file mode 100644 index 000000000000..78003f874421 --- /dev/null +++ b/openupgrade_scripts/scripts/stock_account/18.0.1.1/upgrade_analysis_work.txt @@ -0,0 +1,34 @@ +---Models in module 'stock_account'--- +---Fields in module 'stock_account'--- +stock_account / product.category / property_cost_method (selection): needs conversion to v18-style company dependent +stock_account / product.category / property_stock_account_input_categ_id (many2one): needs conversion to v18-style company dependent +stock_account / product.category / property_stock_account_output_categ_id (many2one): needs conversion to v18-style company dependent +stock_account / product.category / property_stock_journal (many2one): needs conversion to v18-style company dependent +stock_account / product.category / property_stock_valuation_account_id (many2one): needs conversion to v18-style company dependent +stock_account / product.category / property_valuation (selection): needs conversion to v18-style company dependent +# DONE: post-migration: used openupgrade_180.convert_company_dependent + +stock_account / res.company / account_production_wip_account_id (many2one): NEW relation: account.account +stock_account / res.company / account_production_wip_overhead_account_id (many2one): NEW relation: account.account +# DONE: end-migration: call _load_wip_accounts + +stock_account / product.template / lot_valuated (boolean) : NEW hasdefault: compute +stock_account / stock.lot / standard_price (float) : NEW +stock_account / stock.lot / stock_valuation_layer_ids (one2many): NEW relation: stock.valuation.layer +stock_account / stock.valuation.layer / lot_id (many2one) : NEW relation: stock.lot +# NOTHING TO DO: new features + +---XML records in module 'stock_account'--- +NEW ir.actions.act_window: stock_account.action_revalue_layers +DEL ir.actions.act_window: stock_account.inventory_aging_action +# NOTHING TO DO + +DEL ir.property: stock_account.default_category_cost_method (noupdate) +DEL ir.property: stock_account.default_category_valuation (noupdate) +# DONE: post-migration: delete old property safely (now it's an ir.default record created by ORM) + +DEL ir.ui.menu: stock_account.menu_inventory_aging +NEW ir.ui.view: stock_account.view_picking_form +NEW ir.ui.view: stock_account.view_production_lot_form_stock_account +NEW ir.ui.view: stock_account.view_template_property_form_stock_account +# NOTHING TO DO