diff --git a/docsource/modules170-180.rst b/docsource/modules170-180.rst index 44464abd04fa..c33e668e2218 100644 --- a/docsource/modules170-180.rst +++ b/docsource/modules170-180.rst @@ -928,7 +928,7 @@ Module coverage 17.0 -> 18.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | |new| resource_mail | Nothing to do |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| sale | | | +| sale | Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | sale_async_emails | |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/sale/18.0.1.2/end-migration.py b/openupgrade_scripts/scripts/sale/18.0.1.2/end-migration.py new file mode 100644 index 000000000000..a68d0e5842d1 --- /dev/null +++ b/openupgrade_scripts/scripts/sale/18.0.1.2/end-migration.py @@ -0,0 +1,49 @@ +# 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 _setup_property_downpayment_account(env): + # "Copy" of sale _setup_property_downpayment_account + for company in env.companies: + if not company.chart_template or env["product.category"].with_company( + company + ).search_count( + [("property_account_downpayment_categ_id", "!=", False)], limit=1 + ): + continue + # begin patch: avoid having errors for not loading l10n modules + 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 + # end patch + template_data = ( + env["account.chart.template"] + ._get_chart_template_data(company.chart_template) + .get("template_data") + ) + if template_data and template_data.get("property_account_downpayment_categ_id"): + property_downpayment_account = env.ref( + f'account.{company.id}_{template_data["property_account_downpayment_categ_id"]}', + raise_if_not_found=False, + ) + if property_downpayment_account: + env["ir.default"].set( + "product.category", + "property_account_downpayment_categ_id", + property_downpayment_account.id, + company_id=company.id, + ) + + +@openupgrade.migrate() +def migrate(env, version): + _setup_property_downpayment_account(env) diff --git a/openupgrade_scripts/scripts/sale/18.0.1.2/post-migration.py b/openupgrade_scripts/scripts/sale/18.0.1.2/post-migration.py new file mode 100644 index 000000000000..4d4dcfbd7f57 --- /dev/null +++ b/openupgrade_scripts/scripts/sale/18.0.1.2/post-migration.py @@ -0,0 +1,21 @@ +# 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): + openupgrade.load_data(env, "sale", "18.0.1.2/noupdate_changes.xml") + openupgrade.delete_record_translations( + env.cr, "sale", ["email_template_edi_sale", "mail_template_sale_confirmation"] + ) + openupgrade.delete_records_safely_by_xml_id( + env, + [ + "sale.account_invoice_send_rule_see_all", + "sale.account_invoice_send_rule_see_personal", + "sale.onboarding_onboarding_step_sale_order_confirmation", + "sale.onboarding_onboarding_step_sample_quotation", + "sale.onboarding_onboarding_sale_quotation", + ], + ) diff --git a/openupgrade_scripts/scripts/sale/18.0.1.2/pre-migration.py b/openupgrade_scripts/scripts/sale/18.0.1.2/pre-migration.py new file mode 100644 index 000000000000..3a6254dcaa88 --- /dev/null +++ b/openupgrade_scripts/scripts/sale/18.0.1.2/pre-migration.py @@ -0,0 +1,34 @@ +# 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): + openupgrade.rename_fields( + env, + [("product.document", "product_document", "attached_on", "attached_on_sale")], + ) + openupgrade.rename_xmlids( + env.cr, + [ + ( + "sale.sale_order_action_view_quotation_kanban", + "sale.action_quotations_kanban", + ) + ], + ) + openupgrade.add_columns( + env, + [("sale.order.line", "technical_price_unit", "float", None, "sale_order_line")], + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE sale_order_line + SET technical_price_unit = price_unit + """, + ) + openupgrade.delete_sql_constraint_safely( + env, "sale", "sale_order_line", "accountable_required_fields" + ) diff --git a/openupgrade_scripts/scripts/sale/18.0.1.2/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/sale/18.0.1.2/upgrade_analysis_work.txt new file mode 100644 index 000000000000..a2a73855943a --- /dev/null +++ b/openupgrade_scripts/scripts/sale/18.0.1.2/upgrade_analysis_work.txt @@ -0,0 +1,85 @@ +---Models in module 'sale'--- +---Fields in module 'sale'--- +sale / account.analytic.applicability / business_domain (False) : selection_keys is now '['bill', 'expense', 'general', 'invoice', 'manufacturing_order', 'purchase_order', 'sale_order', 'stock_picking', 'timesheet']' ('['bill', 'expense', 'general', 'invoice', 'manufacturing_order', 'purchase_order', 'sale_order']') +# NOTHING TO DO: new options 'stock_picking' and 'timesheet' + +sale / account.move.line / is_downpayment (boolean) : module is now 'purchase' ('sale') +# NOTHING TO DO + +sale / product.category / property_account_downpayment_categ_id (many2one): NEW relation: account.account +# DONE: end-migration: call _setup_property_downpayment_account + +sale / product.document / attached_on (selection) : DEL selection_keys: ['quotation', 'sale_order'] +sale / product.document / attached_on_sale (selection) : NEW required, selection_keys: ['hidden', 'quotation', 'sale_order'], hasdefault: default +# DONE: pre-migration: renamed field + +sale / res.company / sale_down_payment_product_id (many2one): DEL relation: product.product +# NOTHING TO DO: it was unused. Now downpayments use property_account_downpayment_categ_id + +sale / sale.order / amount_to_invoice (float) : not stored anymore +sale / sale.order / analytic_account_id (many2one): DEL relation: account.analytic.account + +sale / sale.order.line / analytic_distribution_search (json): DEL stored: False +# NOTHING TO DO + +sale / sale.order.line / qty_invoiced_posted (float) : previously in module l10n_it_edi_doi +l10n_it_edi_doi / sale.order.line / qty_invoiced_posted (float) : not stored anymore +# NOTHING TO DO + +sale / sale.order.line / combo_item_id (many2one) : NEW relation: product.combo.item +sale / sale.order.line / linked_line_id (many2one) : previously in module website_sale +sale / sale.order.line / linked_line_ids (one2many) : NEW relation: sale.order.line +sale / sale.order.line / linked_virtual_id (char) : NEW +sale / sale.order.line / selected_combo_items (char) : NEW stored: False +sale / sale.order.line / virtual_id (char) : NEW +# NOTHING TO DO + +sale / sale.order.line / technical_price_unit (float) : NEW +# DONE: pre-migration: technical field filled with price_unit + +---XML records in module 'sale'--- +NEW ir.actions.act_window.view: sale.action_quotations_kanban +NEW ir.actions.act_window.view: sale.action_quotations_tree +NEW ir.actions.server: sale.model_sale_order_send_mail +NEW ir.model.access: sale.access_account_move_send_batch_wizard_salesman +NEW ir.model.access: sale.access_account_move_send_wizard_salesman +NEW ir.model.access: sale.access_update_product_attribute_value_sale_manager +DEL ir.model.access: sale.access_account_move_send_salesman +# NOTHING TO DO + +ir.model.constraint: sale.constraint_sale_order_line_accountable_required_fields (changed definition: is now 'check(display_type is not null or is_downpayment or(product_id is not null and product_uom is not null))' ('check(display_type is not null or(product_id is not null and product_uom is not null))')) +# DONE: pre-migration: delete it to force the change + +NEW ir.rule: sale.account_invoice_send_batch_rule_see_all (noupdate) +NEW ir.rule: sale.account_invoice_send_batch_rule_see_personal (noupdate) +NEW ir.rule: sale.account_invoice_send_single_rule_see_all (noupdate) +NEW ir.rule: sale.account_invoice_send_single_rule_see_personal (noupdate) +DEL ir.rule: sale.account_invoice_send_rule_see_all (noupdate) +DEL ir.rule: sale.account_invoice_send_rule_see_personal (noupdate) +# DONE: post-migration: safely delete (we could rename them in pre-migration too, but then we would need to change the field name) + +NEW ir.ui.menu: sale.menu_product_combos +NEW ir.ui.menu: sale.menu_product_tags +NEW ir.ui.menu: sale.sale_menu_config_activities +NEW ir.ui.view: sale.product_template_view_form +NEW ir.ui.view: sale.quote_document_layout_preview +NEW ir.ui.view: sale.sale_order_kanban_upload +NEW ir.ui.view: sale.sale_order_list_upload +NEW ir.ui.view: sale.view_category_property_form +NEW ir.ui.view: sale.view_quotation_kanban_with_onboarding +DEL ir.ui.view: sale_product_configurator.product_template_view_form +DEL ir.ui.view: sale_product_configurator.sale_order_view_form +NEW mail.message.subtype: sale.mt_order_viewed (noupdate) +NEW mail.message.subtype: sale.mt_salesteam_order_viewed (noupdate) +# NOTHING TO DO + +DEL onboarding.onboarding: sale.onboarding_onboarding_sale_quotation (noupdate) +DEL onboarding.onboarding.step: sale.onboarding_onboarding_step_sale_order_confirmation (noupdate) +DEL onboarding.onboarding.step: sale.onboarding_onboarding_step_sample_quotation (noupdate) +# DONE: post-migration: safely delete + +NEW res.groups: sale.group_discount_per_so_line [renamed from product module] +# NOTHING TO DO: rename done in product module + +NEW web_tour.tour: sale.sale_tour +# NOTHING TO DO