|
6 | 6 |
|
7 | 7 | @openupgrade.migrate()
|
8 | 8 | def migrate(env, version):
|
| 9 | + if not openupgrade.table_exists(env.cr, "repair_type"): |
| 10 | + return |
| 11 | + openupgrade.logged_query( |
| 12 | + env.cr, |
| 13 | + """ |
| 14 | + ALTER TABLE stock_picking_type |
| 15 | + ADD COLUMN old_repair_type_id_legacy INTEGER; |
| 16 | + """, |
| 17 | + ) |
9 | 18 | openupgrade.logged_query(
|
10 | 19 | env.cr,
|
11 | 20 | """
|
12 | 21 | INSERT INTO stock_picking_type
|
13 | 22 | (create_date, default_location_dest_id, default_remove_location_dest_id,
|
14 |
| - name,default_add_location_src_id, default_remove_location_src_id) |
| 23 | + name,default_add_location_src_id, default_remove_location_src_id, |
| 24 | + old_repair_type_id_legacy) |
15 | 25 | SELECT create_date, destination_location_add_part_id,
|
16 |
| - destination_location_remove_part_id, name::jsonb, |
17 |
| - source_location_add_part_id, source_location_remove_part_id |
| 26 | + destination_location_remove_part_id, jsonb_build_object('en_US', name) as name, |
| 27 | + source_location_add_part_id, source_location_remove_part_id, id |
18 | 28 | FROM repair_type;
|
19 | 29 | """,
|
20 | 30 | )
|
| 31 | + openupgrade.logged_query( |
| 32 | + env.cr, |
| 33 | + """ |
| 34 | + UPDATE repair_order ro |
| 35 | + SET picking_type_id = spt.id |
| 36 | + FROM stock_picking_type spt |
| 37 | + WHERE ro.repair_type_id = spt.old_repair_type_id_legacy; |
| 38 | + """, |
| 39 | + ) |
21 | 40 | openupgrade.logged_query(
|
22 | 41 | env.cr,
|
23 | 42 | """
|
|
0 commit comments