From b1b09bb981860a2fe71f548af33966625430e0fe Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 26 Dec 2016 18:00:10 +0100 Subject: [PATCH] [MIG] website: Migration scripts + changes for website * Modifications in base module to assign `key` field in views * Modification in compare_noupdate_xml_records for allowing records with empty id * Analysis work * Post-migration script * Doc * Tests --- .../migrations/9.0.1.0/noupdate_changes.xml | 18 +++++ .../9.0.1.0/openupgrade_analysis_work.txt | 78 +++++++++++++++++++ .../migrations/9.0.1.0/post-migration.py | 17 ++++ .../migrations/9.0.1.0/tests/test_website.py | 12 +++ .../9.0.1.3/openupgrade_analysis_work.txt | 4 +- .../base/migrations/9.0.1.3/post-migration.py | 35 ++++++--- .../openupgrade/doc/source/modules80-90.rst | 2 +- scripts/compare_noupdate_xml_records.py | 2 + 8 files changed, 157 insertions(+), 11 deletions(-) create mode 100644 addons/website/migrations/9.0.1.0/noupdate_changes.xml create mode 100644 addons/website/migrations/9.0.1.0/openupgrade_analysis_work.txt create mode 100644 addons/website/migrations/9.0.1.0/post-migration.py create mode 100644 addons/website/migrations/9.0.1.0/tests/test_website.py diff --git a/addons/website/migrations/9.0.1.0/noupdate_changes.xml b/addons/website/migrations/9.0.1.0/noupdate_changes.xml new file mode 100644 index 000000000000..07790256cd1a --- /dev/null +++ b/addons/website/migrations/9.0.1.0/noupdate_changes.xml @@ -0,0 +1,18 @@ + + + + Editor and Designer + + + Editor + + + + + + + + + + + diff --git a/addons/website/migrations/9.0.1.0/openupgrade_analysis_work.txt b/addons/website/migrations/9.0.1.0/openupgrade_analysis_work.txt new file mode 100644 index 000000000000..7c84799ddfe7 --- /dev/null +++ b/addons/website/migrations/9.0.1.0/openupgrade_analysis_work.txt @@ -0,0 +1,78 @@ +---Fields in module 'website'--- +website / ir.actions.server / xml_id (char) : module is now 'base' ('website') +website / ir.attachment / mimetype (char) : module is now 'base' ('website') +# Nothing to do + +website / ir.attachment / website_url (char) : not a function anymore +# Nothing to do: related field not stored + +website / ir.ui.view / website_id (many2one) : NEW relation: website +# Nothing to do: field only for multi-websites (new feature) + +website / website / cdn_activated (boolean) : NEW +website / website / cdn_url (char) : NEW +website / website / compress_html (boolean) : NEW +website / website / domain (char) : NEW +# Nothing to do: default empty values are valid + +website / website / cdn_filters (text) : NEW +# Done: Set default value + +---XML records in module 'website'--- +NEW ir.actions.act_window: website.action_module_theme +NEW ir.attachment: website.business_conference +DEL ir.model.access: website.access_website_converter_test +DEL ir.model.access: website.access_website_converter_test_sub +NEW ir.ui.menu: website.menu_website_global_configuration +NEW ir.ui.view: website.assets_common +NEW ir.ui.view: website.language_selector +NEW ir.ui.view: website.layout_editor +NEW ir.ui.view: website.menu_search +NEW ir.ui.view: website.pdf_js_lib +NEW ir.ui.view: website.s_banner +NEW ir.ui.view: website.s_big_message +NEW ir.ui.view: website.s_big_picture +NEW ir.ui.view: website.s_button +NEW ir.ui.view: website.s_comparisons +NEW ir.ui.view: website.s_faq +NEW ir.ui.view: website.s_faq_collapse +NEW ir.ui.view: website.s_feature_grid +NEW ir.ui.view: website.s_features +NEW ir.ui.view: website.s_image_floating +NEW ir.ui.view: website.s_image_gallery +NEW ir.ui.view: website.s_image_text +NEW ir.ui.view: website.s_panel +NEW ir.ui.view: website.s_parallax +NEW ir.ui.view: website.s_parallax_slider +NEW ir.ui.view: website.s_quote +NEW ir.ui.view: website.s_quotes_slider +NEW ir.ui.view: website.s_references +NEW ir.ui.view: website.s_separator +NEW ir.ui.view: website.s_share +NEW ir.ui.view: website.s_text_block +NEW ir.ui.view: website.s_text_image +NEW ir.ui.view: website.s_text_image_floating +NEW ir.ui.view: website.s_three_columns +NEW ir.ui.view: website.s_title +NEW ir.ui.view: website.s_well +NEW ir.ui.view: website.theme_customize +NEW ir.ui.view: website.view_view_form_extend +NEW ir.ui.view: website.website_planner +NEW ir.ui.view: website.website_search_box +DEL ir.ui.view: website.editor_head +DEL ir.ui.view: website.theme +DEL ir.ui.view: website.theme_amelia +DEL ir.ui.view: website.theme_cerulean +DEL ir.ui.view: website.theme_cosmo +DEL ir.ui.view: website.theme_cyborg +DEL ir.ui.view: website.theme_flatly +DEL ir.ui.view: website.theme_journal +DEL ir.ui.view: website.theme_readable +DEL ir.ui.view: website.theme_simplex +DEL ir.ui.view: website.theme_slate +DEL ir.ui.view: website.theme_spacelab +DEL ir.ui.view: website.theme_united +DEL ir.ui.view: website.theme_yeti +DEL ir.ui.view: website.themes +NEW web.planner: website.planner_website +# Nothing to do diff --git a/addons/website/migrations/9.0.1.0/post-migration.py b/addons/website/migrations/9.0.1.0/post-migration.py new file mode 100644 index 000000000000..886ff06c50ba --- /dev/null +++ b/addons/website/migrations/9.0.1.0/post-migration.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade +from openerp.modules.registry import RegistryManager + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): + pool = RegistryManager.get(env.cr.dbname) + openupgrade.set_defaults( + env.cr, pool, {'website': [('cdn_filters', None)]}, use_orm=True, + ) + openupgrade.load_data( + env.cr, 'website', 'migrations/9.0.1.0/noupdate_changes.xml', + ) diff --git a/addons/website/migrations/9.0.1.0/tests/test_website.py b/addons/website/migrations/9.0.1.0/tests/test_website.py new file mode 100644 index 000000000000..dd2cd7215ddb --- /dev/null +++ b/addons/website/migrations/9.0.1.0/tests/test_website.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from openerp.tests import TransactionCase + + +class TestSale(TransactionCase): + def test_website(self): + self.assertTrue(self.env.ref('website.default_website').cdn_filters) + self.assertEqual( + self.env.ref('website.homepage').key, 'website.homepage', + ) diff --git a/openerp/addons/base/migrations/9.0.1.3/openupgrade_analysis_work.txt b/openerp/addons/base/migrations/9.0.1.3/openupgrade_analysis_work.txt index 66af6a527b98..e4945c3753e3 100644 --- a/openerp/addons/base/migrations/9.0.1.3/openupgrade_analysis_work.txt +++ b/openerp/addons/base/migrations/9.0.1.3/openupgrade_analysis_work.txt @@ -68,8 +68,10 @@ base / ir.ui.view / arch (text) : now a base / ir.ui.view / arch_db (text) : NEW # Done: arch is now arch_db. +base / ir.ui.view / key (char) : NEW +# Done: assign xml_id for views of type 'qweb' + base / ir.ui.view / arch_fs (char) : NEW -base / ir.ui.view / key (char) : NEW base / ir.ui.view / type (selection) : selection_keys is now '['calendar', 'diagram', 'form', 'gantt', 'graph', 'kanban', 'pivot', 'qweb', 'sales_team_dashboard', 'search', 'tree']' ('['calendar', 'diagram', 'form', 'gantt', 'graph', 'kanban', 'qweb', 'search', 'tree']') base / res.company / bank_ids (one2many) : DEL relation: res.partner.bank base / res.company / currency_ids (one2many) : DEL relation: res.currency diff --git a/openerp/addons/base/migrations/9.0.1.3/post-migration.py b/openerp/addons/base/migrations/9.0.1.3/post-migration.py index 68168550b6d7..c2bee6e0044d 100644 --- a/openerp/addons/base/migrations/9.0.1.3/post-migration.py +++ b/openerp/addons/base/migrations/9.0.1.3/post-migration.py @@ -99,14 +99,31 @@ def remove_obsolete_modules(cr, modules_to_remove): ir_module_module.module_uninstall(cr, SUPERUSER_ID, ids) -@openupgrade.migrate() -def migrate(cr, version): +def assign_view_keys(env): + """This is needed for website. Done through ORM as xml_id is a computed + field, so no o(1) process can be done easily, and the number of these + views is limited.""" + views = env['ir.ui.view'].search([ + ('type', '=', 'qweb'), + ('key', '=', False), + ]) + for view in views: + view.key = view.xml_id + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): for table_name in column_copies.keys(): for (old, new, field_type) in column_copies[table_name]: - openupgrade.convert_field_to_html(cr, table_name, openupgrade.get_legacy_name(old), old) - match_company_type_to_is_company(cr) - clear_inherit_id(cr) - rename_your_company(cr) - set_filter_active(cr) - remove_obsolete_modules(cr, ('web_gantt', 'web_graph', 'web_tests')) - openupgrade.load_data(cr, 'base', 'migrations/9.0.1.3/noupdate_changes.xml') + openupgrade.convert_field_to_html( + env.cr, table_name, openupgrade.get_legacy_name(old), old + ) + match_company_type_to_is_company(env.cr) + clear_inherit_id(env.cr) + rename_your_company(env.cr) + set_filter_active(env.cr) + remove_obsolete_modules(env.cr, ('web_gantt', 'web_graph', 'web_tests')) + openupgrade.load_data( + env.cr, 'base', 'migrations/9.0.1.3/noupdate_changes.xml', + ) + assign_view_keys(env) diff --git a/openerp/openupgrade/doc/source/modules80-90.rst b/openerp/openupgrade/doc/source/modules80-90.rst index 2b9b53ecb027..2ca5a48580f6 100644 --- a/openerp/openupgrade/doc/source/modules80-90.rst +++ b/openerp/openupgrade/doc/source/modules80-90.rst @@ -460,7 +460,7 @@ Status : +-----------------------------------+-----------------------------------+ |web_settings_dashboard | | +-----------------------------------+-----------------------------------+ -|website | | +|website | Done | +-----------------------------------+-----------------------------------+ |website_blog | | +-----------------------------------+-----------------------------------+ diff --git a/scripts/compare_noupdate_xml_records.py b/scripts/compare_noupdate_xml_records.py index 4aa2328983d9..eb2ad26b091a 100644 --- a/scripts/compare_noupdate_xml_records.py +++ b/scripts/compare_noupdate_xml_records.py @@ -92,6 +92,8 @@ def process_data_node(data_node): record_nodes = data_node.xpath("./record") for record in record_nodes: xml_id = record.get("id") + if not xml_id: + continue if '.' in xml_id and xml_id.startswith(addon_name + '.'): xml_id = xml_id[len(addon_name) + 1:] for records in records_noupdate, records_update: