From ad3339294df68a8abf274ff98fa88a45bea4753d Mon Sep 17 00:00:00 2001 From: Lukas Tran Date: Wed, 20 Nov 2024 15:46:13 +0700 Subject: [PATCH 1/5] [IMP] remove depcreate class `oe_kanban_global_click` and `oe_kanban_global_click_edit` --- .../migration_scripts/migrate_170_180.py | 22 ++++++++++++ .../module_170_180/views/res_partner.xml | 36 +++++++++++++++++++ .../module_170/views/res_partner.xml | 36 +++++++++++++++++++ 3 files changed, 94 insertions(+) diff --git a/odoo_module_migrate/migration_scripts/migrate_170_180.py b/odoo_module_migrate/migration_scripts/migrate_170_180.py index 930ebf72..e28aa3f9 100644 --- a/odoo_module_migrate/migration_scripts/migrate_170_180.py +++ b/odoo_module_migrate/migration_scripts/migrate_170_180.py @@ -100,8 +100,30 @@ def replace_user_has_groups( logger.error(f"Error processing file {file}: {str(e)}") +def remove_deprecated_kanban_click_classes( + logger, module_path, module_name, manifest_path, migration_steps, tools +): + files_to_process = tools.get_files(module_path, (".xml",)) + + replaces = { + "oe_kanban_global_click_edit": "", + "oe_kanban_global_click": "", + } + + for file in files_to_process: + try: + tools._replace_in_file( + file, + replaces, + log_message=f"Remove deprecated kanban click classes in file: {file}", + ) + except Exception as e: + logger.error(f"Error processing file {file}: {str(e)}") + + class MigrationScript(BaseMigrationScript): _GLOBAL_FUNCTIONS = [ + remove_deprecated_kanban_click_classes, replace_tree_with_list_in_views, replace_chatter_blocks, replace_user_has_groups, diff --git a/tests/data_result/module_170_180/views/res_partner.xml b/tests/data_result/module_170_180/views/res_partner.xml index ff22ea0c..05c6d957 100644 --- a/tests/data_result/module_170_180/views/res_partner.xml +++ b/tests/data_result/module_170_180/views/res_partner.xml @@ -62,4 +62,40 @@ + + + res.partner.view.kanban + res.partner + + + + +
+
+ +
+
+
+
+
+
+
+ + + res.partner.view.kanban + res.partner + + + + +
+
+ +
+
+
+
+
+
+
diff --git a/tests/data_template/module_170/views/res_partner.xml b/tests/data_template/module_170/views/res_partner.xml index 9beaf9b9..9863064e 100644 --- a/tests/data_template/module_170/views/res_partner.xml +++ b/tests/data_template/module_170/views/res_partner.xml @@ -69,4 +69,40 @@ + + + res.partner.view.kanban + res.partner + + + + +
+
+ +
+
+
+
+
+
+
+ + + res.partner.view.kanban + res.partner + + + + +
+
+ +
+
+
+
+
+
+
From 33bdf2e5885e1f4c3c625c26bd65191642bdc884 Mon Sep 17 00:00:00 2001 From: Lukas Tran Date: Wed, 20 Nov 2024 18:36:11 +0700 Subject: [PATCH 2/5] [IMP] remove deprecated `oe_kanban_colorpicker` and warning deprecated `kanban_color`, `kanban_getcolor`, `kanban_getcolorname` --- .../migration_scripts/migrate_170_180.py | 28 +++++++++++++++++++ .../migrate_170_180/kanban_color.yaml | 2 ++ .../module_170_180/views/res_partner.xml | 2 ++ .../module_170/views/res_partner.xml | 8 ++++++ 4 files changed, 40 insertions(+) create mode 100644 odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_color.yaml diff --git a/odoo_module_migrate/migration_scripts/migrate_170_180.py b/odoo_module_migrate/migration_scripts/migrate_170_180.py index e28aa3f9..5450d5fa 100644 --- a/odoo_module_migrate/migration_scripts/migrate_170_180.py +++ b/odoo_module_migrate/migration_scripts/migrate_170_180.py @@ -121,9 +121,37 @@ def remove_deprecated_kanban_click_classes( logger.error(f"Error processing file {file}: {str(e)}") +def replace_kanban_color_picker_widget( + logger, module_path, module_name, manifest_path, migration_steps, tools +): + files_to_process = tools.get_files(module_path, (".xml",)) + + replaces = { + # Case 1: Match any ul tag containing both oe_kanban_colorpicker class and data-field + # Example:
    + # Example:
      + r']*?class="[^"]*?oe_kanban_colorpicker[^"]*?"[^>]*?data-field="([^"]+)"[^>]*?>(?:
    )?': r'', + # Case 2: Same as Case 1 but with data-field appearing before class + # Example:
      + # Example:
        + r']*?data-field="([^"]+)"[^>]*?class="[^"]*?oe_kanban_colorpicker[^"]*?"[^>]*?>(?:
      )?': r'', + } + + for file in files_to_process: + try: + tools._replace_in_file( + file, + replaces, + log_message=f"Replace kanban colorpicker with field widget in file: {file}", + ) + except Exception as e: + logger.error(f"Error processing file {file}: {str(e)}") + + class MigrationScript(BaseMigrationScript): _GLOBAL_FUNCTIONS = [ remove_deprecated_kanban_click_classes, + replace_kanban_color_picker_widget, replace_tree_with_list_in_views, replace_chatter_blocks, replace_user_has_groups, diff --git a/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_color.yaml b/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_color.yaml new file mode 100644 index 00000000..4f073af6 --- /dev/null +++ b/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_color.yaml @@ -0,0 +1,2 @@ +.xml: + (?:t-attf-class|class)="[^"]*(?:kanban_getcolor|kanban_color|kanban_getcolorname)\([^"]*"|class="[^"]*oe_kanban_color_\d+[^"]*": "[18.0] Kanban color methods (kanban_getcolor, kanban_color, kanban_getcolorname) and static color classes (oe_kanban_color_X) have been deprecated in favor of the highlight_color attribute on kanban root node. This attribute will properly color the left border of the kanban cards. No need to set color classes or use color methods anymore. These methods will be removed in 18.0. More details: https://github.com/odoo/odoo/pull/167751" \ No newline at end of file diff --git a/tests/data_result/module_170_180/views/res_partner.xml b/tests/data_result/module_170_180/views/res_partner.xml index 05c6d957..a5227042 100644 --- a/tests/data_result/module_170_180/views/res_partner.xml +++ b/tests/data_result/module_170_180/views/res_partner.xml @@ -74,6 +74,7 @@
      + @@ -92,6 +93,7 @@
      + diff --git a/tests/data_template/module_170/views/res_partner.xml b/tests/data_template/module_170/views/res_partner.xml index 9863064e..b4403d62 100644 --- a/tests/data_template/module_170/views/res_partner.xml +++ b/tests/data_template/module_170/views/res_partner.xml @@ -81,6 +81,10 @@
      +
        @@ -99,6 +103,10 @@
        +
          From 9fa9b676397ef69634eff5889cca8ec67b06bc24 Mon Sep 17 00:00:00 2001 From: Lukas Tran Date: Thu, 21 Nov 2024 15:25:51 +0700 Subject: [PATCH 3/5] [IMP] remove deprecated kanban-tooltip --- .../migration_scripts/migrate_170_180.py | 26 +++++++++++++++++++ .../migrate_170_180/kanban_color.yaml | 2 +- .../module_170_180/views/res_partner.xml | 13 +++++++--- .../module_170/views/res_partner.xml | 18 ++++++++++--- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/odoo_module_migrate/migration_scripts/migrate_170_180.py b/odoo_module_migrate/migration_scripts/migrate_170_180.py index 5450d5fa..fa9a8339 100644 --- a/odoo_module_migrate/migration_scripts/migrate_170_180.py +++ b/odoo_module_migrate/migration_scripts/migrate_170_180.py @@ -148,10 +148,36 @@ def replace_kanban_color_picker_widget( logger.error(f"Error processing file {file}: {str(e)}") +def remove_kanban_tooltip( + logger, module_path, module_name, manifest_path, migration_steps, tools +): + files_to_process = tools.get_files(module_path, (".xml",)) + reg_tooltip_template = ( + r"""]*>[\s\S]*?\s*""" + ) + reg_tooltip_attr = r"""\s+tooltip=["']kanban-tooltip["']""" + + replaces = { + reg_tooltip_template: "", + reg_tooltip_attr: "", + } + + for file in files_to_process: + try: + tools._replace_in_file( + file, + replaces, + log_message=f"Removed kanban tooltip feature in file: {file}", + ) + except Exception as e: + logger.error(f"Error processing file {file}: {str(e)}") + + class MigrationScript(BaseMigrationScript): _GLOBAL_FUNCTIONS = [ remove_deprecated_kanban_click_classes, replace_kanban_color_picker_widget, + remove_kanban_tooltip, replace_tree_with_list_in_views, replace_chatter_blocks, replace_user_has_groups, diff --git a/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_color.yaml b/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_color.yaml index 4f073af6..5cd9e898 100644 --- a/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_color.yaml +++ b/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_color.yaml @@ -1,2 +1,2 @@ .xml: - (?:t-attf-class|class)="[^"]*(?:kanban_getcolor|kanban_color|kanban_getcolorname)\([^"]*"|class="[^"]*oe_kanban_color_\d+[^"]*": "[18.0] Kanban color methods (kanban_getcolor, kanban_color, kanban_getcolorname) and static color classes (oe_kanban_color_X) have been deprecated in favor of the highlight_color attribute on kanban root node. This attribute will properly color the left border of the kanban cards. No need to set color classes or use color methods anymore. These methods will be removed in 18.0. More details: https://github.com/odoo/odoo/pull/167751" \ No newline at end of file + (?:t-attf-class|class)="[^"]*(?:kanban_getcolor|kanban_color|kanban_getcolorname)\([^"]*"|class="[^"]*oe_kanban_color_\d+[^"]*": "[18.0] Kanban color methods (kanban_getcolor, kanban_color, kanban_getcolorname) and static color classes (oe_kanban_color_X) have been deprecated in favor of the highlight_color attribute on kanban root node. This attribute will properly color the left border of the kanban cards. No need to set color classes or use color methods anymore. These methods will be removed in 18.0. More details: https://github.com/odoo/odoo/pull/167751" diff --git a/tests/data_result/module_170_180/views/res_partner.xml b/tests/data_result/module_170_180/views/res_partner.xml index a5227042..d7f47318 100644 --- a/tests/data_result/module_170_180/views/res_partner.xml +++ b/tests/data_result/module_170_180/views/res_partner.xml @@ -10,7 +10,7 @@ - + res.partner.form res.partner @@ -72,7 +72,7 @@
          - +
          @@ -91,7 +91,14 @@
          - +

          + +

          + +

          + +

          +
          diff --git a/tests/data_template/module_170/views/res_partner.xml b/tests/data_template/module_170/views/res_partner.xml index b4403d62..64e6234b 100644 --- a/tests/data_template/module_170/views/res_partner.xml +++ b/tests/data_template/module_170/views/res_partner.xml @@ -10,7 +10,7 @@
          - + res.partner.form res.partner @@ -79,7 +79,7 @@
          - +
            + +
              +
            • kanban-tooltip test
            • +
            +
            - +

            + +

            + +

            + +

            +
              Date: Thu, 21 Nov 2024 16:44:08 +0700 Subject: [PATCH 4/5] [IMP] warning deprecated kanban_image --- .../text_warnings/migrate_170_180/kanban_image.yaml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_image.yaml diff --git a/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_image.yaml b/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_image.yaml new file mode 100644 index 00000000..ff92cd58 --- /dev/null +++ b/odoo_module_migrate/migration_scripts/text_warnings/migrate_170_180/kanban_image.yaml @@ -0,0 +1,2 @@ +.xml: + kanban_image\(['"][^'"]+["']\s*,\s*['"][^'"]+["']\s*,\s*[^)]+\): "[18.0] The kanban_image helper is deprecated in favor of . More details: https://github.com/odoo/odoo/pull/167751/commits/6c5896724abee4cee0a26d0b41de9781c8e51621" From c3d4cfa9174dee464e160822743343739ffae92e Mon Sep 17 00:00:00 2001 From: Lukas Tran Date: Thu, 21 Nov 2024 17:53:25 +0700 Subject: [PATCH 5/5] [IMP] Changed type='edit' to type='open' to open records --- .../migration_scripts/migrate_170_180.py | 24 +++++++++++++++++++ .../module_170_180/views/res_partner.xml | 7 ++++++ .../module_170/views/res_partner.xml | 7 ++++++ 3 files changed, 38 insertions(+) diff --git a/odoo_module_migrate/migration_scripts/migrate_170_180.py b/odoo_module_migrate/migration_scripts/migrate_170_180.py index fa9a8339..5a263cf6 100644 --- a/odoo_module_migrate/migration_scripts/migrate_170_180.py +++ b/odoo_module_migrate/migration_scripts/migrate_170_180.py @@ -173,11 +173,35 @@ def remove_kanban_tooltip( logger.error(f"Error processing file {file}: {str(e)}") +def replace_type_edit( + logger, module_path, module_name, manifest_path, migration_steps, tools +): + """Replace type='edit' with type='open' in elements.""" + files_to_process = tools.get_files(module_path, (".xml",)) + + reg_type_edit = r"""type=["']edit["']""" + + replaces = { + reg_type_edit: 'type="open"', + } + + for file in files_to_process: + try: + tools._replace_in_file( + file, + replaces, + log_message=f"Replaced type='edit' with type='open' in file: {file}", + ) + except Exception as e: + logger.error(f"Error processing file {file}: {str(e)}") + + class MigrationScript(BaseMigrationScript): _GLOBAL_FUNCTIONS = [ remove_deprecated_kanban_click_classes, replace_kanban_color_picker_widget, remove_kanban_tooltip, + replace_type_edit, replace_tree_with_list_in_views, replace_chatter_blocks, replace_user_has_groups, diff --git a/tests/data_result/module_170_180/views/res_partner.xml b/tests/data_result/module_170_180/views/res_partner.xml index d7f47318..2d011a70 100644 --- a/tests/data_result/module_170_180/views/res_partner.xml +++ b/tests/data_result/module_170_180/views/res_partner.xml @@ -101,6 +101,13 @@
            +
          diff --git a/tests/data_template/module_170/views/res_partner.xml b/tests/data_template/module_170/views/res_partner.xml index 64e6234b..2aee9de0 100644 --- a/tests/data_template/module_170/views/res_partner.xml +++ b/tests/data_template/module_170/views/res_partner.xml @@ -119,6 +119,13 @@ data-field="color" modifiers="{}" /> +