-
-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33aff47
commit 0fea456
Showing
5 changed files
with
310 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
openupgrade_scripts/scripts/stock/14.0.1.1/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def propagate_orderpoints_on_moves(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE stock_move sm | ||
SET orderpoint_id = sm2.orderpoint_id | ||
FROM stock_move_move_rel rel | ||
JOIN stock_move sm2 ON rel.move_dest_id = sm2.id | ||
WHERE sm.rule_id IS NOT NULL AND sm.orderpoint_id IS NULL | ||
AND rel.move_orig_id = sm.id AND sm2.orderpoint_id IS NOT NULL""", | ||
) | ||
|
||
|
||
def merge_priorities(env): | ||
openupgrade.map_values( | ||
env.cr, | ||
openupgrade.get_legacy_name("priority"), | ||
"priority", | ||
[("1", "0"), ("2", "1"), ("3", "1")], | ||
table="stock_move", | ||
) | ||
openupgrade.map_values( | ||
env.cr, | ||
openupgrade.get_legacy_name("priority"), | ||
"priority", | ||
[("1", "0"), ("2", "1"), ("3", "1")], | ||
table="stock_picking", | ||
) | ||
|
||
|
||
def recompute_stock_picking_scheduled_date(env): | ||
env.cr.execute( | ||
""" | ||
SELECT sp.id | ||
FROM stock_picking sp | ||
JOIN stock_move sm ON sm.picking_id = sp.id | ||
WHERE sm.state NOT IN ('done', 'cancel')""" | ||
) | ||
picking_ids = [pick[0] for pick in env.cr.fetchall()] | ||
if picking_ids: | ||
pickings = env["stock.picking"].browse(picking_ids) | ||
pickings._compute_scheduled_date() | ||
|
||
|
||
def delete_domain_from_view(env): | ||
view = env.ref("stock.report_stock_quantity_action") | ||
view.domain = None | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
propagate_orderpoints_on_moves(env) | ||
merge_priorities(env) | ||
delete_domain_from_view(env) | ||
openupgrade.load_data(env.cr, "stock", "14.0.1.1/noupdate_changes.xml") | ||
recompute_stock_picking_scheduled_date(env) | ||
openupgrade.delete_record_translations( | ||
env.cr, "stock", ["mail_template_data_delivery_confirmation"] | ||
) |
45 changes: 45 additions & 0 deletions
45
openupgrade_scripts/scripts/stock/14.0.1.1/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
_column_copies = { | ||
"stock_move": [ | ||
("priority", None, None), | ||
], | ||
"stock_picking": [ | ||
("priority", None, None), | ||
], | ||
} | ||
|
||
_field_renames = [("stock.move", "stock_move", "date_expected", "date_deadline")] | ||
|
||
_xmlid_renames = [ | ||
("stock.action_orderpoint_form", "stock.action_orderpoint"), | ||
("stock.access_stock_picking_portal", "sale_stock.access_stock_picking_portal"), | ||
] | ||
|
||
|
||
def fast_precreate_orderpoint_product_category_id(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE stock_warehouse_orderpoint | ||
ADD COLUMN product_category_id integer""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE stock_warehouse_orderpoint swo | ||
SET product_category_id = pt.categ_id | ||
FROM product_product pp | ||
JOIN product_template pt ON pp.product_tmpl_id = pt.id | ||
WHERE swo.product_id = pp.id""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.copy_columns(env.cr, _column_copies) | ||
openupgrade.rename_fields(env, _field_renames) | ||
openupgrade.rename_xmlids(env.cr, _xmlid_renames) | ||
fast_precreate_orderpoint_product_category_id(env) |
173 changes: 173 additions & 0 deletions
173
openupgrade_scripts/scripts/stock/14.0.1.1/upgrade_analysis_work.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
---Models in module 'stock'--- | ||
obsolete model stock.overprocessed.transfer [transient] | ||
obsolete model stock.picking.responsible [transient] | ||
new model report.stock.report_product_product_replenishment [abstract] | ||
new model report.stock.report_product_template_replenishment [abstract] | ||
new model stock.backorder.confirmation.line [transient] | ||
new model stock.immediate.transfer.line [transient] | ||
new model stock.orderpoint.snooze [transient] | ||
# NOTHING TO DO: transient/abstract models | ||
|
||
---Fields in module 'stock'--- | ||
stock / procurement.group / stock_move_ids (one2many) : NEW relation: stock.move | ||
# NOTHING TO DO: one2many | ||
|
||
stock / stock.inventory / activity_ids (one2many) : NEW relation: mail.activity | ||
stock / stock.inventory / message_follower_ids (one2many): NEW relation: mail.followers | ||
stock / stock.inventory / message_ids (one2many) : NEW relation: mail.message | ||
stock / stock.inventory / message_main_attachment_id (many2one): NEW relation: ir.attachment | ||
stock / stock.inventory / website_message_ids (one2many): NEW relation: mail.message | ||
# NOTHING TO DO: from added mail mixins | ||
|
||
stock / stock.inventory / exhausted (boolean) : NEW | ||
# NOTHING TO DO: new feature | ||
|
||
stock / stock.move / date_deadline (datetime) : NEW | ||
stock / stock.move / date_expected (datetime) : DEL required, req_default: function | ||
# DONE: pre-migration: renamed field | ||
|
||
stock / stock.move / delay_alert_date (datetime) : NEW isfunction: function, stored | ||
# NOTHING TO DO: computed during loading | ||
|
||
stock / stock.move / delay_alert (boolean) : DEL | ||
stock / stock.move / propagate_date (boolean) : DEL | ||
stock / stock.move / propagate_date_minimum_delta (integer): DEL | ||
stock / stock.rule / delay_alert (boolean) : DEL | ||
stock / stock.rule / propagate_date (boolean) : DEL | ||
stock / stock.rule / propagate_date_minimum_delta (integer): DEL | ||
# NOTHING TO DO: not used anymore | ||
|
||
stock / stock.move / orderpoint_id (many2one) : NEW relation: stock.warehouse.orderpoint | ||
# DONE: post-migration: filled | ||
|
||
stock / stock.move / priority (selection) : now a function | ||
stock / stock.move / priority (selection) : selection_keys is now '['0', '1']' ('['0', '1', '2', '3']') | ||
# DONE: post-migration: merge 1 to 0, and 2 and 3 to 1 | ||
|
||
stock / stock.picking / _order : _order is now 'priority desc, scheduled_date asc, id desc' ('priority desc, date asc, id desc') | ||
# NOTHING TO DO | ||
|
||
stock / stock.picking / date_deadline (datetime) : NEW isfunction: function, stored | ||
stock / stock.picking / has_deadline_issue (boolean) : NEW hasdefault, isfunction: function, stored | ||
# NOTHING TO DO: computed during loading | ||
|
||
stock / stock.picking / priority (selection) : not a function anymore | ||
stock / stock.picking / priority (selection) : selection_keys is now '['0', '1']' ('['0', '1', '2', '3']') | ||
# DONE: post-migration: merge 1 to 0, and 2 and 3 to 1 | ||
|
||
stock / stock.picking / signature (binary) : NEW attachment: True | ||
# NOTHING TO DO: new feature | ||
|
||
stock / stock.warehouse.orderpoint / _order : _order is now 'location_id,company_id,id' ('id') | ||
# NOTHING TO DO | ||
|
||
stock / stock.warehouse.orderpoint / lead_days (integer) : DEL | ||
stock / stock.warehouse.orderpoint / lead_type (selection) : DEL required, selection_keys: ['net', 'supplier'], req_default: function | ||
# NOTHING TO DO: removed (and seems to be replaced by computed lead_days_date) | ||
|
||
stock / stock.warehouse.orderpoint / product_category_id (many2one): NEW relation: product.category, isrelated: related, stored | ||
# DONE: pre-migration: precreated and fast filled | ||
|
||
stock / stock.warehouse.orderpoint / qty_to_order (float) : NEW isfunction: function, stored | ||
# NOTHING TO DO: computed during loading | ||
|
||
stock / stock.warehouse.orderpoint / route_id (many2one) : NEW relation: stock.location.route | ||
# NOTHING TO DO: replenished only when using new replenish feature | ||
|
||
stock / stock.warehouse.orderpoint / snoozed_until (date) : NEW | ||
# NOTHING TO DO: new feature (used in new wizard stock.orderpoint.snooze) | ||
|
||
stock / stock.warehouse.orderpoint / trigger (selection) : NEW required, selection_keys: ['auto', 'manual'], req_default: function, hasdefault | ||
# NOTHING TO DO: the default is the previous version behaviour | ||
|
||
---XML records in module 'stock'--- | ||
NEW digest.tip: stock.digest_tip_stock_0 | ||
# NOTHING TO DO | ||
|
||
DEL ir.actions.act_window: stock.action_orderpoint_form | ||
NEW ir.actions.act_window: stock.action_orderpoint | ||
# DONE: pre-migration: renamed xmlid | ||
|
||
ir.actions.act_window: stock.report_stock_quantity_action (deleted domain) | ||
# DONE: post-migration: deleted domain | ||
|
||
NEW ir.actions.act_window: stock.action_orderpoint_replenish | ||
NEW ir.actions.act_window: stock.action_orderpoint_snooze | ||
NEW ir.actions.act_window: stock.action_prod_inv_location_form | ||
DEL ir.actions.act_window: stock.act_product_stock_move_open | ||
DEL ir.actions.act_window: stock.action_receipt_picking_move | ||
DEL ir.actions.act_window: stock.product_open_orderpoint | ||
DEL ir.actions.act_window: stock.product_template_open_quants | ||
# NOTHING TO DO | ||
|
||
NEW ir.actions.client: stock.stock_replenishment_product_product_action | ||
NEW ir.actions.report: stock.stock_replenishment_report_product_product_action | ||
NEW ir.actions.report: stock.stock_replenishment_report_product_template_action | ||
NEW ir.actions.server: stock.action_open_routes | ||
NEW ir.actions.server: stock.action_replenishment | ||
NEW ir.actions.server: stock.action_unreserve_picking | ||
NEW ir.actions.server: stock.action_validate_picking | ||
# NOTHING TO DO | ||
|
||
DEL ir.model.access: stock.access_stock_picking_portal [renamed to sale_stock module] | ||
# DONE: pre-migration: renamed xmlid | ||
|
||
NEW ir.model.access: stock.access_product_replenish | ||
NEW ir.model.access: stock.access_stock_assign_serial | ||
NEW ir.model.access: stock.access_stock_backorder_confirmation | ||
NEW ir.model.access: stock.access_stock_backorder_confirmation_line | ||
NEW ir.model.access: stock.access_stock_change_product_qty | ||
NEW ir.model.access: stock.access_stock_immediate_transfer | ||
NEW ir.model.access: stock.access_stock_immediate_transfer_line | ||
NEW ir.model.access: stock.access_stock_location_partner_manager | ||
NEW ir.model.access: stock.access_stock_orderpoint_snooze | ||
NEW ir.model.access: stock.access_stock_package_destination | ||
NEW ir.model.access: stock.access_stock_quantity_history | ||
NEW ir.model.access: stock.access_stock_return_picking | ||
NEW ir.model.access: stock.access_stock_return_picking_line | ||
NEW ir.model.access: stock.access_stock_rules_report | ||
NEW ir.model.access: stock.access_stock_scheduler_compute | ||
NEW ir.model.access: stock.access_stock_traceability_report | ||
NEW ir.model.access: stock.access_stock_track_confirmation | ||
NEW ir.model.access: stock.access_stock_track_line | ||
NEW ir.model.access: stock.access_stock_warn_insufficient_qty_scrap | ||
DEL ir.model.access: stock.access_ir_property_group_stock_manager | ||
DEL ir.model.access: stock.access_stock_location__partner_manager | ||
DEL ir.model.access: stock.access_stock_location_stock_manager | ||
DEL ir.model.access: stock.access_stock_move_line_portal | ||
DEL ir.model.access: stock.access_stock_move_portal | ||
DEL ir.model.access: stock.access_stock_picking_type_portal | ||
DEL ir.model.access: stock.access_stock_rule | ||
DEL ir.model.access: stock.access_stock_rule_manager | ||
DEL ir.model.access: stock.access_stock_warehouse_orderpoint_portal | ||
# NOTHING TO DO | ||
|
||
NEW ir.ui.menu: stock.menu_reordering_rules_replenish | ||
NEW ir.ui.view: stock.assets_common_replenishment_report | ||
NEW ir.ui.view: stock.package_level_form_edit_view | ||
NEW ir.ui.view: stock.report_generic_barcode | ||
NEW ir.ui.view: stock.report_product_product_replenishment | ||
NEW ir.ui.view: stock.report_product_template_replenishment | ||
NEW ir.ui.view: stock.report_replenishment_header | ||
NEW ir.ui.view: stock.stock_inventory_line_tree_no_product_create | ||
NEW ir.ui.view: stock.stock_reorder_report_search | ||
NEW ir.ui.view: stock.stock_report_delivery_aggregated_move_lines | ||
NEW ir.ui.view: stock.stock_report_delivery_has_serial_move_line | ||
NEW ir.ui.view: stock.stock_report_delivery_no_package_section_line | ||
NEW ir.ui.view: stock.stock_report_delivery_package_section_line | ||
NEW ir.ui.view: stock.view_stock_orderpoint_snooze | ||
NEW ir.ui.view: stock.view_stock_quant_form_editable | ||
NEW ir.ui.view: stock.view_warehouse_orderpoint_tree_editable | ||
NEW ir.ui.view: stock.view_warehouse_orderpoint_tree_editable_config | ||
DEL ir.ui.view: stock.stock_inventory_line_tree2 | ||
DEL ir.ui.view: stock.stock_move_tree | ||
DEL ir.ui.view: stock.stock_move_view_kanban | ||
DEL ir.ui.view: stock.stock_warehouse_view_form_editable | ||
DEL ir.ui.view: stock.stock_warehouse_view_tree_editable | ||
DEL ir.ui.view: stock.view_move_picking_tree | ||
DEL ir.ui.view: stock.view_move_tree_receipt_picking_board | ||
DEL ir.ui.view: stock.view_overprocessed_transfer | ||
DEL ir.ui.view: stock.view_stock_move_kanban | ||
DEL ir.ui.view: stock.view_warehouse_orderpoint_tree | ||
NEW res.groups: stock.group_stock_sign_delivery | ||
# NOTHING TO DO |