Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][OU-ADD] delivery: Migration to 17.0 #4637

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docsource/modules160-170.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Module coverage 16.0 -> 17.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| data_recycle | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| delivery | | |
| delivery | Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| delivery_mondialrelay | |No DB layout changes. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env, "delivery", "17.0.1.0/noupdate_changes.xml")
76 changes: 76 additions & 0 deletions openupgrade_scripts/scripts/delivery/17.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
from openupgradelib import openupgrade

_new_fields = [
(
"carrier_id", # Field name
"stock.move.line", # Model name
"stock_move_line", # Table name
"many2one", # Odoo Field type (in lower case)
False, # [Optional] SQL type (if custom fields)
"delivery", # Module name
False, # [Optional] Default value
)
]

_xmlids_renames = [
(
"delivery.act_delivery_trackers_url",
"stock_delivery.act_delivery_trackers_url",
),
(
"delivery.access_choose_delivery_package",
"stock_delivery.access_choose_delivery_package",
),
(
"delivery.access_delivery_carrier_stock_user",
"stock_delivery.access_delivery_carrier_stock_user",
),
(
"delivery.access_delivery_carrier_stock_manager",
"stock_delivery.access_delivery_carrier_stock_manager",
),
(
"delivery.access_delivery_price_rule_stock_manager",
"stock_delivery.access_delivery_price_rule_stock_manager",
),
(
"delivery.access_delivery_zip_prefix_stock_manager",
"stock_delivery.access_delivery_zip_prefix_stock_manager",
),
(
"delivery.menu_action_delivery_carrier_form",
"stock_delivery.menu_action_delivery_carrier_form",
),
(
"delivery.menu_delivery_zip_prefix",
"stock_delivery.menu_delivery_zip_prefix",
),
]


def _delete_sql_constraints(env):
# Delete constraints to recreate it
openupgrade.delete_sql_constraint_safely(
env, "delivery", "delivery_carrier", "margin_not_under_100_percent"
)


def _fill_stock_move_line_carrier_id(env):
"""Field `carrier_id` on stock.move.line is now a stored field."""
openupgrade.logged_query(
env.cr,
"""
UPDATE stock_move_line sml
SET carrier_id = sp.carrier_id
FROM stock_picking sp
WHERE sml.picking_id = sp.id;
""",
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_xmlids(env.cr, _xmlids_renames)
openupgrade.add_fields(env, _new_fields)
_delete_sql_constraints(env)
_fill_stock_move_line_carrier_id(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---Models in module 'delivery'---
model choose.delivery.package (moved to stock_delivery) [column['model_type']]
# DONE: in migration script of module stock_delivery

---Fields in module 'delivery'---
delivery / delivery.carrier / fixed_margin (float) : NEW
delivery / delivery.carrier / invoice_policy (selection) : selection_keys is now '['estimated']' ('['estimated', 'real']')
# NOTHING TO DO:

delivery / sale.order / shipping_weight (float) : NEW hasdefault: compute
# NOTHING TO DO: new features

delivery / stock.move.line / carrier_id (many2one) : is now stored
# DONE: pre-migration: Add new column & set value for it

delivery / stock.move.line / carrier_name (char) : DEL
# NOTHING TO DO:

delivery / product.product / country_of_origin (many2one) : module is now 'stock_delivery' ('delivery')
delivery / product.product / hs_code (char) : module is now 'stock_delivery' ('delivery')
delivery / product.template / country_of_origin (many2one) : module is now 'stock_delivery' ('delivery')
delivery / product.template / hs_code (char) : module is now 'stock_delivery' ('delivery')
delivery / stock.move / weight (float) : module is now 'stock_delivery' ('delivery')
delivery / stock.move.line / carrier_id (many2one) : module is now 'stock_delivery' ('delivery')
delivery / stock.move.line / destination_country_code (char): module is now 'stock_delivery' ('delivery')
delivery / stock.move.line / sale_price (float) : module is now 'stock_delivery' ('delivery')
delivery / stock.package.type / package_carrier_type (selection): module is now 'stock_delivery' ('delivery')
delivery / stock.package.type / shipper_package_code (char) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / carrier_id (many2one) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / carrier_price (float) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / carrier_tracking_ref (char) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / carrier_tracking_url (char) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / delivery_type (selection) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / destination_country_code (char): module is now 'stock_delivery' ('delivery')
delivery / stock.picking / is_return_picking (boolean) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / package_ids (many2many) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / return_label_ids (one2many) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / shipping_weight (float) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / weight (float) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / weight_bulk (float) : module is now 'stock_delivery' ('delivery')
delivery / stock.picking / weight_uom_name (char) : module is now 'stock_delivery' ('delivery')
delivery / stock.quant.package / shipping_weight (float) : module is now 'stock_delivery' ('delivery')
delivery / stock.quant.package / weight (float) : module is now 'stock_delivery' ('delivery')
delivery / stock.quant.package / weight_is_kg (boolean) : module is now 'stock_delivery' ('delivery')
delivery / stock.quant.package / weight_uom_name (char) : module is now 'stock_delivery' ('delivery')
delivery / stock.quant.package / weight_uom_rounding (float) : module is now 'stock_delivery' ('delivery')
# NOTHING TO DO: Handled by ORM

---XML records in module 'delivery'---
DEL ir.actions.act_window: delivery.act_delivery_trackers_url [renamed to stock_delivery module]
# DONE: pre-migration: moved to stock_delivery

NEW ir.model.access: delivery.access_delivery_price_rule_sale_manager
NEW ir.model.access: delivery.access_delivery_zip_prefix_sale_manager
DEL ir.model.access: delivery.access_choose_delivery_carrier_salesman
# NOTHING TO DO

DEL ir.model.access: delivery.access_choose_delivery_package [renamed to stock_delivery module]
DEL ir.model.access: delivery.access_delivery_carrier_stock_manager [renamed to stock_delivery module]
DEL ir.model.access: delivery.access_delivery_carrier_stock_user [renamed to stock_delivery module]
DEL ir.model.access: delivery.access_delivery_price_rule_stock_manager [renamed to stock_delivery module]
DEL ir.model.access: delivery.access_delivery_zip_prefix_stock_manager [renamed to stock_delivery module]
# DONE: pre-migration: moved to stock_delivery

ir.model.constraint: delivery.constraint_delivery_carrier_margin_not_under_100_percent (changed definition: is now 'check(margin >= -1)' ('check(margin >= -100)'))
# DONE pre-migration: safely delete constraint to recreate it

DEL ir.ui.menu: delivery.menu_action_delivery_carrier_form [renamed to stock_delivery module]
DEL ir.ui.menu: delivery.menu_delivery_zip_prefix [renamed to stock_delivery module]
# DONE: pre-migration: moved to stock_delivery

DEL ir.ui.view: delivery.choose_delivery_package_view_form
DEL ir.ui.view: delivery.delivery_stock_report_delivery_no_package_section_line
DEL ir.ui.view: delivery.delivery_tracking_url_warning_form
DEL ir.ui.view: delivery.label_package_template_view_delivery
DEL ir.ui.view: delivery.product_template_hs_code
DEL ir.ui.view: delivery.report_delivery_document2
DEL ir.ui.view: delivery.report_package_barcode_delivery
DEL ir.ui.view: delivery.report_package_barcode_small_delivery
DEL ir.ui.view: delivery.report_shipping2
DEL ir.ui.view: delivery.sale_order_portal_content_inherit_sale_stock_inherit_website_sale_delivery
DEL ir.ui.view: delivery.stock_move_line_view_search_delivery
DEL ir.ui.view: delivery.stock_package_type_form_delivery
DEL ir.ui.view: delivery.stock_package_type_tree_delivery
DEL ir.ui.view: delivery.stock_report_delivery_aggregated_move_lines_inherit_delivery
DEL ir.ui.view: delivery.stock_report_delivery_has_serial_move_line_inherit_delivery
DEL ir.ui.view: delivery.stock_report_delivery_package_section_line_inherit_delivery
DEL ir.ui.view: delivery.view_move_line_tree_detailed_delivery
DEL ir.ui.view: delivery.view_picking_type_form_delivery
DEL ir.ui.view: delivery.view_picking_withcarrier_out_form
DEL ir.ui.view: delivery.view_picking_withweight_internal_move_form
DEL ir.ui.view: delivery.view_quant_package_weight_form
DEL ir.ui.view: delivery.view_stock_rule_form_delivery
DEL ir.ui.view: delivery.vpicktree_view_tree
# NOTHING TO DO
Loading