Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 34 additions & 27 deletions odoo/addons/base/migrations/13.0.1.3/openupgrade_analysis_work.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,61 @@ new model reset.view.arch.wizard [transient]

---Fields in module 'base'---
base / ir.actions.act_url / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
base / ir.actions.act_url / binding_view_types (char) : NEW hasdefault
# NOTHING TO DO

base / ir.actions.act_window / auto_search (boolean) : DEL
base / ir.actions.act_window / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
base / ir.actions.act_window / binding_view_types (char) : NEW hasdefault
base / ir.actions.act_window / multi (boolean) : DEL
base / ir.actions.act_window / src_model (char) : DEL
base / ir.actions.act_window / view_type (selection) : DEL required, selection_keys: ['form', 'tree'], req_default: function
# NOTHING TO DO

base / ir.actions.act_window_close / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
base / ir.actions.act_window_close / binding_view_types (char) : NEW hasdefault
# NOTHING TO DO

base / ir.actions.actions / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
base / ir.actions.actions / binding_view_types (char) : NEW hasdefault
# NOTHING TO DO

base / ir.actions.client / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
base / ir.actions.client / binding_view_types (char) : NEW hasdefault
# NOTHING TO DO

base / ir.actions.report / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
base / ir.actions.report / binding_view_types (char) : NEW hasdefault
# NOTHING TO DO

base / ir.actions.server / binding_type (selection) : selection_keys is now '['action', 'report']' ('['action', 'action_form_only', 'report']')
base / ir.actions.act_url / binding_view_types (char) : NEW hasdefault
base / ir.actions.act_window / binding_view_types (char) : NEW hasdefault
base / ir.actions.act_window_close / binding_view_types (char) : NEW hasdefault
base / ir.actions.actions / binding_view_types (char) : NEW hasdefault
base / ir.actions.client / binding_view_types (char) : NEW hasdefault
base / ir.actions.report / binding_view_types (char) : NEW hasdefault
base / ir.actions.server / binding_view_types (char) : NEW hasdefault
# Done. Set binding_view_types to 'form' where 'action_form_only' was set.

base / ir.actions.act_window / auto_search (boolean) : DEL
base / ir.actions.act_window / multi (boolean) : DEL
# Nothing to do

base / ir.actions.act_window / src_model (char) : DEL
# Done: migrating to binding_model_id if that value is missing

base / ir.actions.act_window / view_type (selection) : DEL required, selection_keys: ['form', 'tree'], req_default: function
# NOTHING TO DO, Obsolete remnant of the old hierarchical 'tree' view.

base / ir.actions.server / groups_id (many2many) : NEW relation: res.groups
# NOTHING TO DO

base / ir.attachment / active (boolean) : DEL
# Nothing to do. This will make attachments that were split up into separate PDFs, or set to inactive manually, visible again
# functionality can be recreated in some customization if required

base / ir.attachment / datas_fname (char) : DEL
# Done: the semantics of the `name` field changed to that of this field (c.q. the filename of the attachment). Renamed columns accordingly.

base / ir.attachment / res_id (integer) : relation is now 'res_model' ('False') [nothing to do]
base / ir.attachment / res_id (integer) : type is now 'many2one_reference' ('integer')
# Nothing to do, artifacts of the new field type

base / ir.attachment / res_model_name (char) : DEL
base / ir.attachment / res_name (char) : not stored anymore
# Nothing to do, removal of denormalized data

base / ir.attachment / thumbnail (binary) : DEL attachment: True
# NOTHING TO DO
# Nothing to do. Replaced by Image mixin

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

base / ir.model.constraint / date_init (datetime) : DEL
base / ir.model.constraint / date_update (datetime) : DEL
# Done, moving data over to create_date/write_date.

base / ir.model.constraint / message (char) : NEW
# NOTHING TO DO
# Nothing to do, populated automatically by the ORM

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

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

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

base / ir.ui.view / arch_prev (text) : NEW
base / ir.ui.view / arch_updated (boolean) : NEW
Expand Down
30 changes: 29 additions & 1 deletion odoo/addons/base/migrations/13.0.1.3/post-migration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright 2020 Andrii Skrypka
# Copyright 2020 Opener B.V. (stefan@opener.amsterdam)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from psycopg2 import sql
from openupgradelib import openupgrade


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


@openupgrade.migrate(use_env=True)
@openupgrade.migrate()
def migrate(env, version):
fix_res_lang_url_code(env)
restore_res_lang_week_start(env)
openupgrade.load_data(env.cr, 'base', 'migrations/13.0.1.3/noupdate_changes.xml')
fix_res_partner_image(env)

# Populate missing binding_model_id values in ir_act_window
openupgrade.logged_query(
env.cr,
""" UPDATE ir_act_window iaw
SET binding_model_id = im.id
FROM ir_model im
WHERE binding_model_id IS NULL
AND src_model IS NOT NULL
AND iaw.src_model = im.model; """)
# Convert obsolete 'action_form_only' binding type to binding_view_types
openupgrade.logged_query(
env.cr,
""" UPDATE ir_actions
SET binding_view_types = 'form', binding_type = 'action'
WHERE binding_type = 'action_form_only' """)
# Set new name column from old name column if missing
openupgrade.logged_query(
env.cr,
sql.SQL(""" UPDATE ir_attachment
SET name = {legacy_name}
WHERE COALESCE(name, '') = ''
AND COALESCE({legacy_name}, '') != '' """).format(
legacy_name=sql.Identifier(
openupgrade.get_legacy_name('name'))))
28 changes: 26 additions & 2 deletions odoo/addons/base/migrations/13.0.1.3/pre-migration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright 2020 Andrii Skrypka
# Copyright 2020 Opener B.V. (stefan@opener.amsterdam)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade
Expand Down Expand Up @@ -463,11 +465,21 @@
]

column_renames = {
'ir_attachment': [
('name', None),
('datas_fname', 'name'),
],
'res_lang': [
('week_start', None),
],
}

field_renames = [
('ir.server.object.lines',
'ir_server_object_lines',
'type', 'evaluation_type'),
]


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


@openupgrade.migrate(use_env=True)
@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_columns(env.cr, column_renames)
openupgrade.rename_fields(env, field_renames, no_deep=True)
openupgrade.update_module_names(
env.cr, apriori.renamed_modules.items())
openupgrade.update_module_names(
Expand All @@ -490,3 +503,14 @@ def migrate(env, version):
openupgrade.rename_xmlids(env.cr, xmlid_renames_ir_module_category)
openupgrade.rename_xmlids(env.cr, xmlid_renames_ir_model_access)
fix_lang_table(env.cr)

openupgrade.logged_query(
env.cr,
""" UPDATE ir_model_constraint
SET create_date = date_init
WHERE create_date IS NULL AND date_init IS NOT NULL """)
openupgrade.logged_query(
env.cr,
""" UPDATE ir_model_constraint
SET write_date = date_update
WHERE write_date IS NULL AND date_update IS NOT NULL """)