Skip to content

Commit 91593a5

Browse files
committed
Merge PR #2210 into 13.0
Signed-off-by legalsylvain
2 parents 1c0027a + 55c69a4 commit 91593a5

File tree

4 files changed

+98
-30
lines changed

4 files changed

+98
-30
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# © 2020 Opener B.V. (stefan@opener.amsterdam)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
from openupgradelib import openupgrade
4+
5+
6+
@openupgrade.migrate()
7+
def migrate(env, version):
8+
""" Call disable_invalid_filters in every edition of openupgrade """
9+
openupgrade.disable_invalid_filters(env)

odoo/addons/base/migrations/13.0.1.3/openupgrade_analysis_work.txt

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,61 @@ new model reset.view.arch.wizard [transient]
99

1010
---Fields in module 'base'---
1111
base / ir.actions.act_url / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
12-
base / ir.actions.act_url / binding_view_types (char) : NEW hasdefault
13-
# NOTHING TO DO
14-
15-
base / ir.actions.act_window / auto_search (boolean) : DEL
1612
base / ir.actions.act_window / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
17-
base / ir.actions.act_window / binding_view_types (char) : NEW hasdefault
18-
base / ir.actions.act_window / multi (boolean) : DEL
19-
base / ir.actions.act_window / src_model (char) : DEL
20-
base / ir.actions.act_window / view_type (selection) : DEL required, selection_keys: ['form', 'tree'], req_default: function
21-
# NOTHING TO DO
22-
2313
base / ir.actions.act_window_close / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
24-
base / ir.actions.act_window_close / binding_view_types (char) : NEW hasdefault
25-
# NOTHING TO DO
26-
2714
base / ir.actions.actions / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
28-
base / ir.actions.actions / binding_view_types (char) : NEW hasdefault
29-
# NOTHING TO DO
30-
3115
base / ir.actions.client / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
32-
base / ir.actions.client / binding_view_types (char) : NEW hasdefault
33-
# NOTHING TO DO
34-
3516
base / ir.actions.report / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
36-
base / ir.actions.report / binding_view_types (char) : NEW hasdefault
37-
# NOTHING TO DO
38-
3917
base / ir.actions.server / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
18+
base / ir.actions.act_url / binding_view_types (char) : NEW hasdefault
19+
base / ir.actions.act_window / binding_view_types (char) : NEW hasdefault
20+
base / ir.actions.act_window_close / binding_view_types (char) : NEW hasdefault
21+
base / ir.actions.actions / binding_view_types (char) : NEW hasdefault
22+
base / ir.actions.client / binding_view_types (char) : NEW hasdefault
23+
base / ir.actions.report / binding_view_types (char) : NEW hasdefault
4024
base / ir.actions.server / binding_view_types (char) : NEW hasdefault
25+
# Done. Set binding_view_types to 'form' where 'action_form_only' was set.
26+
27+
base / ir.actions.act_window / auto_search (boolean) : DEL
28+
base / ir.actions.act_window / multi (boolean) : DEL
29+
# Nothing to do
30+
31+
base / ir.actions.act_window / src_model (char) : DEL
32+
# Done: migrating to binding_model_id if that value is missing
33+
34+
base / ir.actions.act_window / view_type (selection) : DEL required, selection_keys: ['form', 'tree'], req_default: function
35+
# NOTHING TO DO, Obsolete remnant of the old hierarchical 'tree' view.
36+
4137
base / ir.actions.server / groups_id (many2many) : NEW relation: res.groups
4238
# NOTHING TO DO
4339

4440
base / ir.attachment / active (boolean) : DEL
41+
# Nothing to do. This will make attachments that were split up into separate PDFs, or set to inactive manually, visible again
42+
# functionality can be recreated in some customization if required
43+
4544
base / ir.attachment / datas_fname (char) : DEL
45+
# Done: the semantics of the `name` field changed to that of this field (c.q. the filename of the attachment). Renamed columns accordingly.
46+
4647
base / ir.attachment / res_id (integer) : relation is now 'res_model' ('False') [nothing to do]
4748
base / ir.attachment / res_id (integer) : type is now 'many2one_reference' ('integer')
49+
# Nothing to do, artifacts of the new field type
50+
4851
base / ir.attachment / res_model_name (char) : DEL
4952
base / ir.attachment / res_name (char) : not stored anymore
53+
# Nothing to do, removal of denormalized data
54+
5055
base / ir.attachment / thumbnail (binary) : DEL attachment: True
51-
# NOTHING TO DO
56+
# Nothing to do. Replaced by Image mixin
5257

5358
base / ir.cron / lastcall (datetime) : NEW
54-
# NOTHING TO DO
59+
# Nothing to do, just for reference. Will be filled after next call
5560

5661
base / ir.model.constraint / date_init (datetime) : DEL
5762
base / ir.model.constraint / date_update (datetime) : DEL
63+
# Done, moving data over to create_date/write_date.
64+
5865
base / ir.model.constraint / message (char) : NEW
59-
# NOTHING TO DO
66+
# Nothing to do, populated automatically by the ORM
6067

6168
base / ir.model.fields / selection (char) : not stored anymore
6269
base / ir.model.fields / selection (char) : now a function
@@ -79,10 +86,10 @@ base / ir.module.module.dependency / auto_install_required (boolean): NE
7986

8087
base / ir.server.object.lines / evaluation_type (selection) : NEW required, selection_keys: ['equation', 'reference', 'value'], req_default: function, hasdefault
8188
base / ir.server.object.lines / type (selection) : DEL required, selection_keys: ['equation', 'reference', 'value'], req_default: function
82-
# NOTHING TO DO
89+
# Done, renamed column
8390

8491
base / ir.translation / type (selection) : selection_keys is now '['code', 'model', 'model_terms']' ('['code', 'constraint', 'model', 'model_terms', 'selection', 'sql_constraint']')
85-
# NOTHING TO DO
92+
# TODO: for now, this means that existing, customized translations for selection values and constraint errors will be overwritten by the default translations.
8693

8794
base / ir.ui.view / arch_prev (text) : NEW
8895
base / ir.ui.view / arch_updated (boolean) : NEW

odoo/addons/base/migrations/13.0.1.3/post-migration.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Copyright 2020 Andrii Skrypka
2+
# Copyright 2020 Opener B.V. (stefan@opener.amsterdam)
13
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
24

5+
from psycopg2 import sql
36
from openupgradelib import openupgrade
47

58

@@ -37,9 +40,34 @@ def restore_res_lang_week_start(env):
3740
env['res.lang'].browse(lang_ids).write({'week_start': str(week_start)})
3841

3942

40-
@openupgrade.migrate(use_env=True)
43+
@openupgrade.migrate()
4144
def migrate(env, version):
4245
fix_res_lang_url_code(env)
4346
restore_res_lang_week_start(env)
4447
openupgrade.load_data(env.cr, 'base', 'migrations/13.0.1.3/noupdate_changes.xml')
4548
fix_res_partner_image(env)
49+
50+
# Populate missing binding_model_id values in ir_act_window
51+
openupgrade.logged_query(
52+
env.cr,
53+
""" UPDATE ir_act_window iaw
54+
SET binding_model_id = im.id
55+
FROM ir_model im
56+
WHERE binding_model_id IS NULL
57+
AND src_model IS NOT NULL
58+
AND iaw.src_model = im.model; """)
59+
# Convert obsolete 'action_form_only' binding type to binding_view_types
60+
openupgrade.logged_query(
61+
env.cr,
62+
""" UPDATE ir_actions
63+
SET binding_view_types = 'form', binding_type = 'action'
64+
WHERE binding_type = 'action_form_only' """)
65+
# Set new name column from old name column if missing
66+
openupgrade.logged_query(
67+
env.cr,
68+
sql.SQL(""" UPDATE ir_attachment
69+
SET name = {legacy_name}
70+
WHERE COALESCE(name, '') = ''
71+
AND COALESCE({legacy_name}, '') != '' """).format(
72+
legacy_name=sql.Identifier(
73+
openupgrade.get_legacy_name('name'))))

odoo/addons/base/migrations/13.0.1.3/pre-migration.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright 2020 Andrii Skrypka
2+
# Copyright 2020 Opener B.V. (stefan@opener.amsterdam)
13
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
24

35
from openupgradelib import openupgrade
@@ -463,11 +465,21 @@
463465
]
464466

465467
column_renames = {
468+
'ir_attachment': [
469+
('name', None),
470+
('datas_fname', 'name'),
471+
],
466472
'res_lang': [
467473
('week_start', None),
468474
],
469475
}
470476

477+
field_renames = [
478+
('ir.server.object.lines',
479+
'ir_server_object_lines',
480+
'type', 'evaluation_type'),
481+
]
482+
471483

472484
def fix_lang_table(cr):
473485
"""Avoid error on normal update process due to changed language codes"""
@@ -477,11 +489,12 @@ def fix_lang_table(cr):
477489
"UPDATE res_lang SET code=%s WHERE code=%s",
478490
(new_code, old_code)
479491
)
480-
openupgrade.rename_columns(cr, column_renames)
481492

482493

483-
@openupgrade.migrate(use_env=True)
494+
@openupgrade.migrate()
484495
def migrate(env, version):
496+
openupgrade.rename_columns(env.cr, column_renames)
497+
openupgrade.rename_fields(env, field_renames, no_deep=True)
485498
openupgrade.update_module_names(
486499
env.cr, apriori.renamed_modules.items())
487500
openupgrade.update_module_names(
@@ -490,3 +503,14 @@ def migrate(env, version):
490503
openupgrade.rename_xmlids(env.cr, xmlid_renames_ir_module_category)
491504
openupgrade.rename_xmlids(env.cr, xmlid_renames_ir_model_access)
492505
fix_lang_table(env.cr)
506+
507+
openupgrade.logged_query(
508+
env.cr,
509+
""" UPDATE ir_model_constraint
510+
SET create_date = date_init
511+
WHERE create_date IS NULL AND date_init IS NOT NULL """)
512+
openupgrade.logged_query(
513+
env.cr,
514+
""" UPDATE ir_model_constraint
515+
SET write_date = date_update
516+
WHERE write_date IS NULL AND date_update IS NOT NULL """)

0 commit comments

Comments
 (0)