diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index a4c8f5f61d28..58f788e35996 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -720,7 +720,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | sale_sms | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| sale_stock | | | +| sale_stock | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ | sale_stock_margin | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/sale_stock/16.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/sale_stock/16.0.1.0/pre-migration.py new file mode 100644 index 000000000000..86c9234a9eba --- /dev/null +++ b/openupgrade_scripts/scripts/sale_stock/16.0.1.0/pre-migration.py @@ -0,0 +1,57 @@ +# Copyright 2023 Coop IT Easy SC +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +def compute_sale_order_delivery_status(env): + openupgrade.add_fields( + env, + [ + ( + "delivery_status", + "sale.order", + False, + "selection", + False, + "sale_stock", + ) + ], + ) + openupgrade.logged_query( + env.cr, + """ + with so_delivery_status as ( + select + sale_id as id, + case + when + count(state) filter ( + where state = 'cancel' + ) = count(state) + then null + when + count(state) filter ( + where state not in ('done', 'cancel') + ) = 0 + then 'full' + when + count(state) filter (where state = 'done') > 0 + then 'partial' + else 'pending' + end as delivery_status + from stock_picking + group by 1 + order by 1 + ) + update sale_order as so + set delivery_status = so_delivery_status.delivery_status + from so_delivery_status + where so_delivery_status.id = so.id; + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + compute_sale_order_delivery_status(env) diff --git a/openupgrade_scripts/scripts/sale_stock/16.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/sale_stock/16.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..a9230552603d --- /dev/null +++ b/openupgrade_scripts/scripts/sale_stock/16.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,16 @@ +---Models in module 'sale_stock'--- +---Fields in module 'sale_stock'--- +sale_stock / sale.order / delivery_status (selection) : NEW selection_keys: ['full', 'partial', 'pending'], isfunction: function, stored +# DONE: pre-migration: fast computed delivery_status +sale_stock / sale.order / incoterm_location (char) : NEW +sale_stock / sale.order.line / product_type (selection) : module is now 'sale' ('sale_stock') +sale_stock / sale.order.line / route_id (many2one) : relation is now 'stock.route' ('stock.location.route') [nothing to do] +sale_stock / stock.location.route / sale_selectable (boolean) : DEL +sale_stock / stock.route / sale_selectable (boolean) : NEW +# NOTHING TO DO +---XML records in module 'sale_stock'--- +DEL ir.ui.menu: sale_stock.menu_aftersale +DEL ir.ui.menu: sale_stock.menu_invoiced +DEL ir.ui.view: sale_stock.product_template_view_form_inherit_sale +DEL ir.ui.view: sale_stock.product_template_view_form_inherit_stock +# NOTHING TO DO