Skip to content

Commit fda9382

Browse files
[OU-ADD] stock: migration
1 parent 39ee0f0 commit fda9382

4 files changed

Lines changed: 321 additions & 1 deletion

File tree

docsource/modules150-160.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ Module coverage 15.0 -> 16.0
768768
+-------------------------------------------------+----------------------+-------------------------------------------------+
769769
| |new| spreadsheet_dashboard_website_sale_slides | | |
770770
+-------------------------------------------------+----------------------+-------------------------------------------------+
771-
| stock | | |
771+
| stock | Done | |
772772
+-------------------------------------------------+----------------------+-------------------------------------------------+
773773
| stock_account | | |
774774
+-------------------------------------------------+----------------------+-------------------------------------------------+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from openupgradelib import openupgrade
2+
3+
4+
@openupgrade.migrate()
5+
def migrate(env, version):
6+
openupgrade.load_data(env.cr, "stock", "16.0.1.1/noupdate_changes.xml")
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
from openupgradelib import openupgrade
2+
3+
_models_renames = [
4+
("stock.location.route", "stock.route"),
5+
("stock.production.lot", "stock.lot"),
6+
]
7+
8+
_tables_renames = [
9+
("stock_location_route", "stock_route"),
10+
("stock_production_lot", "stock_lot"),
11+
("stock_location_route_categ", "stock_route_categ"),
12+
("stock_location_route_packaging", "stock_route_packaging"),
13+
("stock_location_route_move", "stock_route_move"),
14+
]
15+
16+
_columns_renames = {
17+
"stock_move_line": [
18+
("product_qty", "reserved_qty"),
19+
("product_uom_qty", "reserved_uom_qty"),
20+
],
21+
"stock_rule": [
22+
("location_id", "location_dest_id"),
23+
],
24+
}
25+
26+
_fields_renames = [
27+
("stock.picking", "stock_picking", "move_lines", "move_ids"),
28+
]
29+
30+
31+
def stock_quant_storage_category_id(env):
32+
openupgrade.logged_query(
33+
env.cr,
34+
"""
35+
ALTER TABLE stock_quant
36+
ADD COLUMN IF NOT EXISTS storage_category_id INTEGER
37+
""",
38+
)
39+
openupgrade.logged_query(
40+
env.cr,
41+
"""
42+
UPDATE stock_quant
43+
SET storage_category_id = stock_location.storage_category_id
44+
FROM stock_location
45+
WHERE stock_quant.location_id = stock_location.id
46+
""",
47+
)
48+
49+
50+
def sol_product_category_name(env):
51+
openupgrade.logged_query(
52+
env.cr,
53+
"""
54+
ALTER TABLE stock_move_line
55+
ADD COLUMN IF NOT EXISTS product_category_name CHARACTER VARYING
56+
""",
57+
)
58+
openupgrade.logged_query(
59+
env.cr,
60+
"""
61+
UPDATE stock_move_line AS sml
62+
SET product_category_name = category.complete_name
63+
FROM product_product AS product
64+
JOIN product_template AS product_tmpl
65+
ON product_tmpl.id = product.product_tmpl_id
66+
JOIN product_category AS category
67+
ON category.id = product_tmpl.categ_id
68+
WHERE sml.product_id = product.id
69+
""",
70+
)
71+
72+
73+
def stock_location_replenish_location(env):
74+
openupgrade.logged_query(
75+
env.cr,
76+
"""
77+
ALTER TABLE stock_location
78+
ADD COLUMN IF NOT EXISTS replenish_location BOOLEAN
79+
""",
80+
)
81+
openupgrade.logged_query(
82+
env.cr,
83+
"""
84+
UPDATE stock_location
85+
SET replenish_location = CASE
86+
WHEN usage = 'internal' THEN TRUE ELSE FALSE
87+
END
88+
""",
89+
)
90+
91+
92+
@openupgrade.migrate()
93+
def migrate(env, version):
94+
openupgrade.rename_tables(env.cr, _tables_renames)
95+
openupgrade.rename_models(env.cr, _models_renames)
96+
openupgrade.rename_fields(env, _fields_renames)
97+
openupgrade.rename_columns(env.cr, _columns_renames)
98+
stock_quant_storage_category_id(env)
99+
sol_product_category_name(env)
100+
stock_location_replenish_location(env)
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
---Models in module 'stock'---
2+
obsolete model stock.location.route
3+
obsolete model stock.production.lot
4+
# DONE: pre-migration: renamed model
5+
6+
new model lot.label.layout [transient]
7+
new model picking.label.type [transient]
8+
# NOTHING TO DO
9+
10+
new model stock.lot
11+
# DONE: pre-migration: renamed model
12+
13+
new model stock.replenishment.option [transient]
14+
# NOTHING TO DO
15+
16+
new model stock.route
17+
# DONE: pre-migration: renamed model
18+
19+
---Fields in module 'stock'---
20+
stock / barcode.rule / type (False) : selection_keys is now '['alias', 'expiration_date', 'location', 'location_dest', 'lot', 'pack_date', 'package', 'package_type', 'product', 'quantity', 'use_date', 'weight']' ('['alias', 'expiration_date', 'location', 'location_dest', 'lot', 'package', 'package_type', 'packaging_date', 'product', 'quantity', 'use_date', 'weight']')
21+
# NOTHING TO DO: no keys change in module
22+
23+
stock / product.category / route_ids (many2many) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
24+
# NOTHING TO DO
25+
26+
stock / product.category / route_ids (many2many) : table is now 'stock_route_categ' ('stock_location_route_categ')
27+
# DONE: pre-migration: renamed table
28+
29+
stock / product.category / total_route_ids (many2many) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
30+
stock / product.packaging / route_ids (many2many) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
31+
# NOTHING TO DO
32+
33+
stock / product.packaging / route_ids (many2many) : table is now 'stock_route_packaging' ('stock_location_route_packaging')
34+
# DONE: pre-migration: renamed table
35+
36+
stock / product.product / route_from_categ_ids (many2many): relation is now 'stock.route' ('stock.location.route') [nothing to do]
37+
stock / product.product / route_ids (many2many) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
38+
# NOTHING TO DO
39+
40+
stock / product.template / detailed_type (False) : selection_keys is now '['consu', 'product', 'service']' ('['consu', 'gift', 'product', 'service']')
41+
# NOTHING TO DO: no keys changhe in module
42+
43+
stock / product.template / route_from_categ_ids (many2many): relation is now 'stock.route' ('stock.location.route') [nothing to do]
44+
# NOTHING TO DO
45+
46+
stock / product.template / route_from_categ_ids (many2many): table is now 'stock.route' ('stock.location.route')
47+
# NOTHING TO DO: related fields
48+
49+
stock / product.template / route_ids (many2many) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
50+
# NOTHING TO DO
51+
52+
stock / stock.location / replenish_location (boolean) : NEW hasdefault: compute
53+
#DONE: pre-migration: create column and fill values
54+
55+
stock / stock.location / warehouse_id (many2one) : is now stored
56+
# NOTHING TO DO: handle by ORM
57+
58+
stock / stock.location.route / active (boolean) : DEL
59+
stock / stock.location.route / categ_ids (many2many) : DEL relation: product.category
60+
stock / stock.location.route / company_id (many2one) : DEL relation: res.company
61+
stock / stock.location.route / name (char) : DEL required
62+
stock / stock.location.route / packaging_ids (many2many) : DEL relation: product.packaging
63+
stock / stock.location.route / packaging_selectable (boolean): DEL
64+
stock / stock.location.route / product_categ_selectable (boolean): DEL
65+
stock / stock.location.route / product_ids (many2many) : DEL relation: product.template
66+
stock / stock.location.route / product_selectable (boolean) : DEL
67+
stock / stock.location.route / rule_ids (one2many) : DEL relation: stock.rule
68+
stock / stock.location.route / sequence (integer) : DEL
69+
stock / stock.location.route / supplied_wh_id (many2one) : DEL relation: stock.warehouse
70+
stock / stock.location.route / supplier_wh_id (many2one) : DEL relation: stock.warehouse
71+
stock / stock.location.route / warehouse_ids (many2many) : DEL relation: stock.warehouse
72+
stock / stock.location.route / warehouse_selectable (boolean): DEL
73+
# NOTHING TO DO: handle by ORM
74+
75+
stock / stock.lot / activity_ids (one2many) : NEW relation: mail.activity
76+
stock / stock.lot / company_id (many2one) : NEW relation: res.company, required
77+
stock / stock.lot / message_follower_ids (one2many): NEW relation: mail.followers
78+
stock / stock.lot / message_ids (one2many) : NEW relation: mail.message
79+
stock / stock.lot / message_main_attachment_id (many2one): NEW relation: ir.attachment
80+
stock / stock.lot / name (char) : NEW required, hasdefault: default
81+
stock / stock.lot / note (html) : NEW
82+
stock / stock.lot / product_id (many2one) : NEW relation: product.product, required
83+
stock / stock.lot / product_uom_id (many2one) : NEW relation: uom.uom, isrelated: related, stored
84+
stock / stock.lot / quant_ids (one2many) : NEW relation: stock.quant
85+
stock / stock.lot / ref (char) : NEW
86+
stock / stock.lot / website_message_ids (one2many): NEW relation: mail.message
87+
# NOTHING TO DO: handle by ORM
88+
89+
stock / stock.move / lot_ids (many2many) : relation is now 'stock.lot' ('stock.production.lot') [nothing to do]
90+
# NOTHING TO DO
91+
92+
stock / stock.move / quantity_done (float) : is now stored
93+
# NOTHING TO DO: handle by ORM, can improve in the future
94+
95+
stock / stock.move / route_ids (many2many) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
96+
# NOTHING TO DO
97+
98+
stock / stock.move / route_ids (many2many) : table is now 'stock_route_move' ('stock_location_route_move')
99+
# DONE: pre-migration: renamed table
100+
101+
stock / stock.move.line / lot_id (many2one) : relation is now 'stock.lot' ('stock.production.lot') [nothing to do]
102+
# NOTHING TO DO
103+
104+
stock / stock.move.line / product_category_name (char) : NEW isrelated: related, stored
105+
# DONE: pre-migratiion: create column and fill values
106+
107+
stock / stock.move.line / product_qty (float) : DEL
108+
stock / stock.move.line / product_uom_qty (float) : DEL required
109+
stock / stock.move.line / reserved_qty (float) : NEW isfunction: function, stored
110+
stock / stock.move.line / reserved_uom_qty (float) : NEW required, hasdefault: default
111+
# DONE: pre-migration: rename columns
112+
113+
stock / stock.package.type / base_weight (float) : NEW
114+
# NOTHING TO DO
115+
116+
stock / stock.picking / move_ids (one2many) : NEW relation: stock.move
117+
stock / stock.picking / move_lines (one2many) : DEL relation: stock.move
118+
# DONE: pre-migration: rename fields
119+
120+
stock / stock.picking.type / auto_show_reception_report (boolean): NEW
121+
stock / stock.picking.type / create_backorder (selection) : NEW required, selection_keys: ['always', 'ask', 'never'], hasdefault: default
122+
# NOTHING TO DO
123+
124+
stock / stock.production.lot / activity_ids (one2many) : DEL relation: mail.activity
125+
stock / stock.production.lot / company_id (many2one) : DEL relation: res.company, required
126+
stock / stock.production.lot / message_follower_ids (one2many): DEL relation: mail.followers
127+
stock / stock.production.lot / message_ids (one2many) : DEL relation: mail.message
128+
stock / stock.production.lot / message_main_attachment_id (many2one): DEL relation: ir.attachment
129+
stock / stock.production.lot / name (char) : DEL required
130+
stock / stock.production.lot / note (html) : DEL
131+
stock / stock.production.lot / product_id (many2one) : DEL relation: product.product, required
132+
stock / stock.production.lot / product_uom_id (many2one) : DEL relation: uom.uom
133+
stock / stock.production.lot / quant_ids (one2many) : DEL relation: stock.quant
134+
stock / stock.production.lot / ref (char) : DEL
135+
stock / stock.production.lot / website_message_ids (one2many): DEL relation: mail.message
136+
# NOTHING TO DO: handle by ORM
137+
138+
stock / stock.quant / lot_id (many2one) : relation is now 'stock.lot' ('stock.production.lot') [nothing to do]
139+
# NOTHING TO DO
140+
141+
stock / stock.quant / storage_category_id (many2one): NEW relation: stock.storage.category, isrelated: related, stored
142+
# DONE: pre-migration: create column and fill values
143+
144+
stock / stock.quant.package / pack_date (date) : NEW hasdefault: default
145+
# NOTHING TO DO
146+
147+
stock / stock.route / active (boolean) : NEW hasdefault: default
148+
stock / stock.route / categ_ids (many2many) : NEW relation: product.category
149+
stock / stock.route / company_id (many2one) : NEW relation: res.company, hasdefault: default
150+
stock / stock.route / name (char) : NEW required
151+
stock / stock.route / packaging_ids (many2many) : NEW relation: product.packaging
152+
stock / stock.route / packaging_selectable (boolean): NEW
153+
stock / stock.route / product_categ_selectable (boolean): NEW
154+
stock / stock.route / product_ids (many2many) : NEW relation: product.template
155+
stock / stock.route / product_selectable (boolean) : NEW hasdefault: default
156+
stock / stock.route / rule_ids (one2many) : NEW relation: stock.rule
157+
stock / stock.route / sequence (integer) : NEW hasdefault: default
158+
stock / stock.route / supplied_wh_id (many2one) : NEW relation: stock.warehouse
159+
stock / stock.route / supplier_wh_id (many2one) : NEW relation: stock.warehouse
160+
stock / stock.route / warehouse_ids (many2many) : NEW relation: stock.warehouse
161+
stock / stock.route / warehouse_selectable (boolean): NEW
162+
# NOTHING TO DO: handle by ORM
163+
164+
stock / stock.rule / location_dest_id (many2one) : NEW relation: stock.location, required
165+
stock / stock.rule / location_id (many2one) : DEL relation: stock.location, required
166+
# DONE: pre-migration: renamed columns
167+
168+
stock / stock.rule / route_id (many2one) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
169+
stock / stock.scrap / lot_id (many2one) : relation is now 'stock.lot' ('stock.production.lot') [nothing to do]
170+
# NOTHING TO DO
171+
172+
stock / stock.scrap / scrap_qty (float) : now a function
173+
# NOTHING TO DO: handle by ORM
174+
175+
stock / stock.warehouse / crossdock_route_id (many2one) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
176+
stock / stock.warehouse / delivery_route_id (many2one) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
177+
stock / stock.warehouse / reception_route_id (many2one) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
178+
stock / stock.warehouse / resupply_route_ids (one2many) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
179+
stock / stock.warehouse / route_ids (many2many) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
180+
stock / stock.warehouse.orderpoint / route_id (many2one) : relation is now 'stock.route' ('stock.location.route') [nothing to do]
181+
# NOTHING TO DO
182+
183+
---XML records in module 'stock'---
184+
NEW ir.actions.act_window: stock.action_product_stock_view
185+
DEL ir.actions.act_window: stock.report_stock_quantity_action
186+
DEL ir.actions.act_window: stock.report_stock_quantity_action_product
187+
NEW ir.actions.report: stock.action_report_picking_packages
188+
DEL ir.actions.report: stock.stock_replenishment_report_product_product_action
189+
DEL ir.actions.report: stock.stock_replenishment_report_product_template_action
190+
NEW ir.actions.server: stock.action_revert_inventory_adjustment
191+
NEW ir.model.access: stock.access_product_tag_stock_manager
192+
NEW ir.model.access: stock.access_stock_lot_label_layout_user
193+
NEW ir.model.access: stock.access_stock_lot_user
194+
NEW ir.model.access: stock.access_stock_picking_label_type_user
195+
NEW ir.model.access: stock.access_stock_replenish_option
196+
DEL ir.model.access: stock.access_stock_production_lot_user
197+
NEW ir.ui.menu: stock.menu_product_stock
198+
DEL ir.ui.menu: stock.menu_forecast_inventory
199+
DEL ir.ui.menu: stock.menu_storage_categoty_capacity_config
200+
NEW ir.ui.view: stock.duplicated_sn_warning
201+
NEW ir.ui.view: stock.lot_label_layout_form_picking
202+
NEW ir.ui.view: stock.picking_label_type_form
203+
NEW ir.ui.view: stock.product_product_stock_tree
204+
NEW ir.ui.view: stock.product_search_form_view_stock_report
205+
NEW ir.ui.view: stock.replenishment_option_tree_view
206+
NEW ir.ui.view: stock.replenishment_option_warning_view
207+
NEW ir.ui.view: stock.report_picking_packages
208+
DEL ir.ui.view: stock.stock_report_view_search
209+
DEL ir.ui.view: stock.view_warehouse_orderpoint_tree_editable_config
210+
NEW res.groups: stock.group_stock_lot_print_gs1
211+
DEL res.groups: stock.group_auto_reception_report
212+
DEL stock.location.route: stock.route_warehouse0_mto (noupdate)
213+
NEW stock.route: stock.route_warehouse0_mto (noupdate)
214+
# NOTHINGH TO DO

0 commit comments

Comments
 (0)