diff --git a/docsource/modules190-200.rst b/docsource/modules190-200.rst index 8da46d62bbc..4e66d27d7bc 100644 --- a/docsource/modules190-200.rst +++ b/docsource/modules190-200.rst @@ -1076,7 +1076,7 @@ Module coverage 19.0 -> 20.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | stock_account | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| stock_delivery | | | +| stock_delivery |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | stock_dropshipping | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/stock_delivery/20.0.1.0/post-migration.py b/openupgrade_scripts/scripts/stock_delivery/20.0.1.0/post-migration.py new file mode 100644 index 00000000000..fd861d4aa54 --- /dev/null +++ b/openupgrade_scripts/scripts/stock_delivery/20.0.1.0/post-migration.py @@ -0,0 +1,47 @@ +# Copyright 2026 Don Kendall +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + +# Both moved from the template to the variant, and both are plain stored Char / +# Many2one on either side, so the values copy straight across. +_MOVED = ("hs_code", "country_of_origin") + + +@openupgrade.migrate() +def migrate(env, version): + """hs_code and country_of_origin move from product.template to product.product. + + 19.0 stored both on product.template. 20.0 stores them on product.product + and leaves the template a *computed, non-stored* view of its single variant, + with an inverse that writes back. So the direction reverses, and the + template column stops being read at all. + + OpenUpgrade keeps that column, which is what makes this quiet: nothing + raises, no constraint is missed, and every product simply comes out of the + upgrade with no HS code and no origin. On a customs-declaring database that + is the whole of the data. + + Every variant of a template takes the template's value, because in 19.0 the + value applied to the template as a whole. 20.0's own compute only surfaces a + variant value back onto the template when there is exactly one variant, + which is a display rule rather than a reason to migrate fewer rows. + + Nothing to assert on the seed: both columns are empty there in 19.0 and in + 20.0 alike, so this is one the dataset cannot discriminate -- the evidence + is the pair of field definitions, not a row count. + """ + for field in _MOVED: + if not openupgrade.column_exists(env.cr, "product_template", field): + continue + openupgrade.logged_query( + env.cr, + f""" + UPDATE product_product pp + SET {field} = pt.{field} + FROM product_template pt + WHERE pt.id = pp.product_tmpl_id + AND pt.{field} IS NOT NULL + AND pp.{field} IS NULL + """, + ) diff --git a/openupgrade_scripts/scripts/stock_delivery/20.0.1.0/upgrade_analysis.txt b/openupgrade_scripts/scripts/stock_delivery/20.0.1.0/upgrade_analysis.txt new file mode 100644 index 00000000000..a8b0a947966 --- /dev/null +++ b/openupgrade_scripts/scripts/stock_delivery/20.0.1.0/upgrade_analysis.txt @@ -0,0 +1,53 @@ +---Models in module 'stock_delivery'--- +new model pay.on.delivery [transient] +---Fields in module 'stock_delivery'--- +stock_delivery / product.product / country_of_origin (many2one) : is now stored +stock_delivery / product.product / country_of_origin (many2one) : not related anymore +stock_delivery / product.product / hs_code (char) : is now stored +stock_delivery / product.product / hs_code (char) : not related anymore +stock_delivery / product.template / country_of_origin (many2one) : not stored anymore +stock_delivery / product.template / country_of_origin (many2one) : now a function +stock_delivery / product.template / hs_code (char) : not stored anymore +stock_delivery / product.template / hs_code (char) : now a function +stock_delivery / res.partner / pickup_location_data (json) : NEW +stock_delivery / stock.picking.type / auto_print_carrier_labels (boolean): NEW +stock_delivery / stock.picking.type / auto_print_export_documents (boolean): NEW +---XML records in module 'stock_delivery'--- +NEW ir.access: stock_delivery.access_choose_delivery_carrier_stock_user +NEW ir.access: stock_delivery.access_delivery_carrier_stock_manager +NEW ir.access: stock_delivery.access_delivery_carrier_stock_user +NEW ir.access: stock_delivery.access_delivery_price_rule_stock_manager +NEW ir.access: stock_delivery.access_delivery_price_rule_stock_user +NEW ir.access: stock_delivery.access_delivery_zip_prefix_stock_manager +NEW ir.access: stock_delivery.access_delivery_zip_prefix_stock_user +NEW ir.access: stock_delivery.access_pay_on_delivery_sale_user +NEW ir.access: stock_delivery.access_pay_on_delivery_stock_user +NEW ir.access: stock_delivery.access_printer_stock_manager +NEW ir.actions.act_window: stock_delivery.open_export_docs_report +NEW ir.actions.act_window: stock_delivery.open_shipping_labels_report +NEW ir.actions.report: stock_delivery.action_report_shipping_docs +NEW ir.actions.report: stock_delivery.action_report_shipping_labels +DEL ir.model.access: stock_delivery.access_choose_delivery_carrier_stock_user +DEL ir.model.access: stock_delivery.access_delivery_carrier_stock_manager +DEL ir.model.access: stock_delivery.access_delivery_carrier_stock_user +DEL ir.model.access: stock_delivery.access_delivery_price_rule_stock_manager +DEL ir.model.access: stock_delivery.access_delivery_price_rule_stock_user +DEL ir.model.access: stock_delivery.access_delivery_zip_prefix_stock_manager +DEL ir.model.access: stock_delivery.access_delivery_zip_prefix_stock_user +NEW ir.ui.menu: stock_delivery.cached_printers_action +NEW ir.ui.menu: stock_delivery.cached_printers_section +NEW ir.ui.menu: stock_delivery.manage_printers_action +NEW ir.ui.view: stock_delivery.barcode_alternative_label +NEW ir.ui.view: stock_delivery.barcode_normal_label +NEW ir.ui.view: stock_delivery.package_pdf_label_delivery +NEW ir.ui.view: stock_delivery.package_zpl_label_delivery +NEW ir.ui.view: stock_delivery.pay_on_delivery_form +NEW ir.ui.view: stock_delivery.product_product_hs_code +NEW ir.ui.view: stock_delivery.product_product_hs_code_list +NEW ir.ui.view: stock_delivery.report_shipping_docs +NEW ir.ui.view: stock_delivery.report_shipping_labels +DEL ir.ui.view: delivery_stock_picking_batch.view_picking_type_form_inherit +DEL ir.ui.view: stock_delivery.alternative_zpl_label +DEL ir.ui.view: stock_delivery.label_package_template_view_delivery +DEL ir.ui.view: stock_delivery.normal_zpl_label +DEL ir.ui.view: stock_delivery.report_package_barcode_small_delivery diff --git a/openupgrade_scripts/scripts/stock_delivery/20.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/stock_delivery/20.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 00000000000..e820cf2f5ce --- /dev/null +++ b/openupgrade_scripts/scripts/stock_delivery/20.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,82 @@ +---Models in module 'stock_delivery'--- +new model pay.on.delivery [transient] +# NOTHING TO DO: a transient model holds no persistent data +---Fields in module 'stock_delivery'--- +stock_delivery / product.product / country_of_origin (many2one) : is now stored +# NOTHING TO DO: the field is stored in 20.0 and filled by its own compute. +# Every field the analysis flags that is stored and entirely empty afterwards +# was checked one by one; the only pair whose emptiness meant a lost value was +# stock_delivery's hs_code and country_of_origin, which now have a script +stock_delivery / product.product / country_of_origin (many2one) : not related anymore +# NOTHING TO DO: the field stops reading through a relation and stands on its +# own. Checked across the upgrade: it comes out with no fewer values than before +stock_delivery / product.product / hs_code (char) : is now stored +# NOTHING TO DO: the field is stored in 20.0 and filled by its own compute. +# Every field the analysis flags that is stored and entirely empty afterwards +# was checked one by one; the only pair whose emptiness meant a lost value was +# stock_delivery's hs_code and country_of_origin, which now have a script +stock_delivery / product.product / hs_code (char) : not related anymore +# NOTHING TO DO: the field stops reading through a relation and stands on its +# own. Checked across the upgrade: it comes out with no fewer values than before +stock_delivery / product.template / country_of_origin (many2one) : not stored anymore +# NOTHING TO DO: no longer stored; the column is left in place for database_cleanup +stock_delivery / product.template / country_of_origin (many2one) : now a function +# NOTHING TO DO: the field is stored in 20.0 and filled by its own compute. +# Every field the analysis flags that is stored and entirely empty afterwards +# was checked one by one; the only pair whose emptiness meant a lost value was +# stock_delivery's hs_code and country_of_origin, which now have a script +stock_delivery / product.template / hs_code (char) : not stored anymore +# NOTHING TO DO: no longer stored; the column is left in place for database_cleanup +stock_delivery / product.template / hs_code (char) : now a function +# NOTHING TO DO: the field is stored in 20.0 and filled by its own compute. +# Every field the analysis flags that is stored and entirely empty afterwards +# was checked one by one; the only pair whose emptiness meant a lost value was +# stock_delivery's hs_code and country_of_origin, which now have a script +stock_delivery / res.partner / pickup_location_data (json) : NEW +stock_delivery / stock.picking.type / auto_print_carrier_labels (boolean): NEW +stock_delivery / stock.picking.type / auto_print_export_documents (boolean): NEW +# NOTHING TO DO: empty is the right value for existing records +---XML records in module 'stock_delivery'--- +NEW ir.access: stock_delivery.access_choose_delivery_carrier_stock_user +NEW ir.access: stock_delivery.access_delivery_carrier_stock_manager +NEW ir.access: stock_delivery.access_delivery_carrier_stock_user +NEW ir.access: stock_delivery.access_delivery_price_rule_stock_manager +NEW ir.access: stock_delivery.access_delivery_price_rule_stock_user +NEW ir.access: stock_delivery.access_delivery_zip_prefix_stock_manager +NEW ir.access: stock_delivery.access_delivery_zip_prefix_stock_user +NEW ir.access: stock_delivery.access_pay_on_delivery_sale_user +NEW ir.access: stock_delivery.access_pay_on_delivery_stock_user +NEW ir.access: stock_delivery.access_printer_stock_manager +# NOTHING TO DO: base folds ir.model.access and ir.rule into ir.access, keeping the xml_ids +NEW ir.actions.act_window: stock_delivery.open_export_docs_report +NEW ir.actions.act_window: stock_delivery.open_shipping_labels_report +NEW ir.actions.report: stock_delivery.action_report_shipping_docs +NEW ir.actions.report: stock_delivery.action_report_shipping_labels +# NOTHING TO DO: the record is not noupdate, so the module update creates it +DEL ir.model.access: stock_delivery.access_choose_delivery_carrier_stock_user +DEL ir.model.access: stock_delivery.access_delivery_carrier_stock_manager +DEL ir.model.access: stock_delivery.access_delivery_carrier_stock_user +DEL ir.model.access: stock_delivery.access_delivery_price_rule_stock_manager +DEL ir.model.access: stock_delivery.access_delivery_price_rule_stock_user +DEL ir.model.access: stock_delivery.access_delivery_zip_prefix_stock_manager +DEL ir.model.access: stock_delivery.access_delivery_zip_prefix_stock_user +# NOTHING TO DO: base folds ir.model.access and ir.rule into ir.access, keeping the xml_ids +NEW ir.ui.menu: stock_delivery.cached_printers_action +NEW ir.ui.menu: stock_delivery.cached_printers_section +NEW ir.ui.menu: stock_delivery.manage_printers_action +NEW ir.ui.view: stock_delivery.barcode_alternative_label +NEW ir.ui.view: stock_delivery.barcode_normal_label +NEW ir.ui.view: stock_delivery.package_pdf_label_delivery +NEW ir.ui.view: stock_delivery.package_zpl_label_delivery +NEW ir.ui.view: stock_delivery.pay_on_delivery_form +NEW ir.ui.view: stock_delivery.product_product_hs_code +NEW ir.ui.view: stock_delivery.product_product_hs_code_list +NEW ir.ui.view: stock_delivery.report_shipping_docs +NEW ir.ui.view: stock_delivery.report_shipping_labels +# NOTHING TO DO: the record is not noupdate, so the module update creates it +DEL ir.ui.view: delivery_stock_picking_batch.view_picking_type_form_inherit +DEL ir.ui.view: stock_delivery.alternative_zpl_label +DEL ir.ui.view: stock_delivery.label_package_template_view_delivery +DEL ir.ui.view: stock_delivery.normal_zpl_label +DEL ir.ui.view: stock_delivery.report_package_barcode_small_delivery +# NOTHING TO DO: the record is not noupdate, so the module update removes it