Skip to content

Commit 9e31d29

Browse files
committed
fixup! [IMP] base v19 migration (NOT DONE)
1 parent 68e6e39 commit 9e31d29

3 files changed

Lines changed: 192 additions & 0 deletions

File tree

openupgrade_scripts/scripts/base/19.0.1.3/post-migration.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,58 @@ def _ir_actions_server_child_ids(env):
2929
)
3030

3131

32+
def _ir_actions_server_html_value(env):
33+
"""
34+
For evaluation_type 'value' and update_field_id.ttype == 'html',
35+
new field html_value is used
36+
"""
37+
for action in env["ir.actions.server"].search(
38+
[
39+
("state", "=", "object_write"),
40+
("evaluation_type", "=", "value"),
41+
("update_field_id.ttype", "=", "html"),
42+
]
43+
):
44+
action.write({"html_value": action.value})
45+
46+
47+
def _ir_filters_user_ids(env):
48+
"""
49+
m2o user_id has been transformed to m2m user_ids
50+
"""
51+
openupgrade.m2o_to_x2m(
52+
env.cr, env["ir.filters"], env["ir.filters"]._table, "user_ids", "user_id"
53+
)
54+
55+
56+
def _res_lang(env):
57+
"""
58+
Char fields date_format, grouping and time_format have been dumbed down to
59+
selection fields. Keep their original value in a legacy column, and map existing
60+
values not in the selection to the default value
61+
"""
62+
ResLang = env["res.lang"]
63+
for field_name in ("date_format", "time_format", "grouping"):
64+
field = ResLang._fields[field_name]
65+
openupgrade.copy_columns(env.cr, {"res_lang": [(field_name, None, None)]})
66+
openupgrade.logged_query(
67+
env.cr,
68+
f"UPDATE res_lang SET {field_name}=%(default)s "
69+
f"WHERE {field_name} NOT IN %(selection)s",
70+
{
71+
"default": field.default(ResLang),
72+
"selection": tuple(
73+
value for value, _string in field._description_selection(env)
74+
),
75+
},
76+
)
77+
78+
3279
@openupgrade.migrate()
3380
def migrate(env, version):
81+
openupgrade.load_data(env, "base", "19.0.1.3/noupdate_changes.xml")
3482
_ir_actions_act_window_target(env)
3583
_ir_actions_server_child_ids(env)
84+
_ir_actions_server_html_value(env)
85+
_ir_filters_user_ids(env)
86+
_res_lang(env)

openupgrade_scripts/scripts/base/19.0.1.3/pre-migration.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,30 @@
122122
"groups_id",
123123
"group_ids",
124124
),
125+
(
126+
"ir.actions.server",
127+
"ir_act_report_xml",
128+
"groups_id",
129+
"group_ids",
130+
),
131+
(
132+
"ir.ui.menu",
133+
"ir_ui_menu",
134+
"groups_id",
135+
"group_ids",
136+
),
137+
(
138+
"ir.ui.view",
139+
"ir_ui_view",
140+
"groups_id",
141+
"group_ids",
142+
),
143+
(
144+
"res.groups",
145+
"res_groups",
146+
"users",
147+
"user_ids",
148+
),
125149
]
126150

127151

openupgrade_scripts/scripts/base/19.0.1.3/upgrade_analysis_work.txt

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,77 +45,194 @@ base / ir.actions.server / child_ids (many2many) : type i
4545
# DONE: set from m2m table in post-migration
4646

4747
base / ir.actions.server / crud_model_id (many2one) : now a function
48+
49+
# NOTHING TO DO: same computation function
50+
4851
base / ir.actions.server / evaluation_type (selection) : selection_keys added: [sequence] (most likely nothing to do)
52+
53+
# NOTHING TO DO
54+
4955
base / ir.actions.server / group_ids (many2many) : NEW relation: res.groups
5056
base / ir.actions.server / groups_id (many2many) : DEL relation: res.groups
57+
58+
# DONE: renamed groups_id to group_ids in pre-migration
59+
5160
base / ir.actions.server / html_value (html) : NEW
61+
62+
# DONE: filled from value in post-migration
63+
5264
base / ir.actions.server / ir_cron_ids (one2many) : NEW relation: ir.cron
65+
66+
# NOTHING TO DO: inverse of ir.cron#ir_actions_server_id
67+
5368
base / ir.actions.server / model_name (char) : not stored anymore
69+
70+
# NOTHING TO DO
71+
5472
base / ir.actions.server / parent_id (many2one) : NEW relation: ir.actions.server
73+
74+
# DONE: see above for child_ids
75+
5576
base / ir.actions.server / sequence_id (many2one) : NEW relation: ir.sequence
77+
78+
# NOTHING TO DO: new field for evaluation_type == 'sequence'
79+
5680
base / ir.actions.server / state (selection) : selection_keys added: [object_copy] (most likely nothing to do)
5781
base / ir.actions.server / value_field_to_show (selection): selection_keys added: [html_value, sequence_id] (most likely nothing to do)
82+
83+
# NOTHING TO DO
84+
5885
base / ir.actions.server.history / action_id (many2one) : NEW relation: ir.actions.server, required
5986
base / ir.actions.server.history / code (text) : NEW
87+
88+
# NOTHING TO DO: v19 keeps a history of code changes
89+
6090
base / ir.cron / _order : _order is now 'cron_name, id' ('cron_name')
91+
92+
# NOTHING TO DO
93+
6194
base / ir.cron / child_ids (many2many) : type is now 'one2many' ('many2many')
95+
96+
# NOTHING TO DO: inherited from ir.actions.server, handled there
97+
6298
base / ir.cron.trigger / call_at (datetime) : now required
6399
base / ir.cron.trigger / cron_id (many2one) : now required
100+
101+
# NOTHING TO DO: old records with missing fields will be cleaned up eventually
102+
64103
base / ir.exports / _order : _order is now 'name, id' ('name')
104+
105+
# NOTHING TO DO
106+
65107
base / ir.filters / user_id (many2one) : DEL relation: res.users
66108
base / ir.filters / user_ids (many2many) : NEW relation: res.users
109+
110+
# DONE: openupgrade.m2o_to_x2m in post-migration
111+
67112
base / ir.mail_server / smtp_encryption (selection) : selection_keys added: [ssl_strict, starttls_strict] (most likely nothing to do)
113+
114+
# NOTHING TO DO
115+
68116
base / ir.model / abstract (boolean) : NEW
69117
base / ir.model / fold_name (char) : NEW
118+
119+
# NOTHING TO DO: filled by orm
120+
70121
base / ir.model.fields / _order : _order is now 'name, id' ('name')
71122
base / ir.model.fields / complete_name (char) : DEL
123+
124+
# NOTHING TO DO
125+
72126
base / ir.model.fields / translate (boolean) : selection_keys is now '['html_translate', 'standard', 'xml_translate']' ('False')
73127
base / ir.model.fields / translate (boolean) : type is now 'selection' ('boolean')
74128

75129
# DONE: set column to NULL where it was FALSE in openupgrade_framework, because migration scripts are too late for it
76130

77131
base / ir.module.category / _order : _order is now 'sequence, name, id' ('name')
132+
133+
# NOTHING TO DO: we want to have the ordering by sequence as provided by Odoo
134+
78135
base / ir.module.category / privilege_ids (one2many) : NEW relation: res.groups.privilege
136+
137+
# NOTHING TO DO: new concept
138+
79139
base / ir.profile / cpu_duration (float) : NEW
80140
base / ir.profile / others (text) : NEW
141+
142+
# NOTHING TO DO: new funcitonality, no way of generating this data
143+
81144
base / ir.sequence / _order : _order is now 'name, id' ('name')
145+
146+
# NOTHING TO DO
147+
82148
base / ir.ui.menu / group_ids (many2many) : NEW relation: res.groups
83149
base / ir.ui.menu / groups_id (many2many) : DEL relation: res.groups
84150
base / ir.ui.view / group_ids (many2many) : NEW relation: res.groups
85151
base / ir.ui.view / groups_id (many2many) : DEL relation: res.groups
152+
153+
# DONE: renamed groups_id to group_ids in pre-migration
154+
86155
base / ir.ui.view.custom / _order : _order is now 'create_date desc, id desc' ('create_date desc')
156+
157+
# NOTHING TO DO
158+
87159
base / properties.base.definition / properties_definition (properties_definition): NEW
88160
base / properties.base.definition / properties_field_id (many2one): NEW relation: ir.model.fields, required
161+
162+
# NOTHING TO DO: filled by orm
163+
89164
base / report.layout / _order : _order is now 'sequence, id' ('sequence')
90165
base / res.bank / _order : _order is now 'name, id' ('name')
91166
base / res.company / company_registry_placeholder (char): previously in module account
167+
168+
# NOTHING TO DO
169+
92170
base / res.company / mobile (char) : DEL
171+
172+
# NOTHING TO DO: possibly some oca module will pick this up again
173+
93174
base / res.country / _order : _order is now 'name, id' ('name')
175+
176+
# NOTHING TO DO: possibly some oca module will pick this up again
177+
94178
base / res.country.group / code (char) : NEW
179+
180+
# NOTHING TO DO: filled in noupdate_changes.xml
181+
95182
base / res.country.state / _order : _order is now 'code, id' ('code')
96183
base / res.currency.rate / _order : _order is now 'name desc, id' ('name desc')
97184
base / res.groups / _order : _order is now 'privilege_id, sequence, name, id' ('name')
185+
186+
# NOTHING TO DO
187+
98188
base / res.groups / category_id (many2one) : DEL relation: ir.module.category
189+
190+
# NOTHING TO DO: code provided groups will set their own privilege if applicable, manually created ones will have to be assigned to whatever privilege makes sense
191+
99192
base / res.groups / color (integer) : DEL
193+
194+
# NOTHING TO DO
195+
100196
base / res.groups / implied_by_ids (many2many) : NEW relation: res.groups
197+
198+
# NOTHING TO DO: inverse of existing relation
199+
101200
base / res.groups / privilege_id (many2one) : NEW relation: res.groups.privilege
201+
202+
# NOTHING TO DO: new concept
203+
102204
base / res.groups / sequence (integer) : NEW
205+
206+
# NOTHING TO DO
207+
103208
base / res.groups / user_ids (many2many) : NEW relation: res.users
104209
base / res.groups / users (many2many) : DEL relation: res.users
210+
211+
# DONE: renamed field in pre-migration
212+
105213
base / res.groups.privilege / category_id (many2one) : NEW relation: ir.module.category
106214
base / res.groups.privilege / description (text) : NEW
107215
base / res.groups.privilege / group_ids (one2many) : NEW relation: res.groups
108216
base / res.groups.privilege / name (char) : NEW required, translate
109217
base / res.groups.privilege / placeholder (char) : NEW hasdefault: default
110218
base / res.groups.privilege / sequence (integer) : NEW hasdefault: default
219+
220+
# NOTHING TO DO: new concept
221+
111222
base / res.lang / date_format (char) : selection_keys is now 'function' ('False')
112223
base / res.lang / date_format (char) : type is now 'selection' ('char')
113224
base / res.lang / grouping (char) : selection_keys is now '['[3,0]', '[3,2,0]']' ('False')
114225
base / res.lang / grouping (char) : type is now 'selection' ('char')
115226
base / res.lang / short_time_format (char) : DEL required
116227
base / res.lang / time_format (char) : selection_keys is now '['%H:%M:%S', '%I:%M:%S %p']' ('False')
117228
base / res.lang / time_format (char) : type is now 'selection' ('char')
229+
230+
# DONE: copy original values to legacy column, map values not in selection to default value
231+
118232
base / res.partner / mobile (char) : DEL
233+
234+
# NOTHING TO DO: possibly some oca module will pick this up again
235+
119236
base / res.partner / properties (properties) : NEW hasdefault: compute
120237
base / res.partner / title (many2one) : DEL relation: res.partner.title
121238
base / res.partner.bank / clearing_number (char) : NEW

0 commit comments

Comments
 (0)