From d1d43236c61769c70a4c279316cf286146188665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Duy=20=28=C4=90=E1=BB=97=20Anh=29?= Date: Mon, 21 Oct 2024 11:01:13 +0700 Subject: [PATCH] [IMG] slugify deprecation --- .../migration_scripts/migrate_170_180.py | 33 +++++++++++++++++++ tests/data_result/module_170_180/__init__.py | 1 + .../module_170_180/controllers/__init__.py | 1 + .../module_170_180/controllers/main.py | 9 +++++ .../module_170_180/models/__init__.py | 1 + .../module_170_180/models/website.py | 9 +++++ tests/data_template/module_170/__init__.py | 1 + .../module_170/controllers/__init__.py | 1 + .../module_170/controllers/main.py | 10 ++++++ .../module_170/models/__init__.py | 1 + .../module_170/models/website.py | 10 ++++++ 11 files changed, 77 insertions(+) create mode 100644 tests/data_result/module_170_180/controllers/__init__.py create mode 100644 tests/data_result/module_170_180/controllers/main.py create mode 100644 tests/data_result/module_170_180/models/website.py create mode 100644 tests/data_template/module_170/controllers/__init__.py create mode 100644 tests/data_template/module_170/controllers/main.py create mode 100644 tests/data_template/module_170/models/website.py diff --git a/odoo_module_migrate/migration_scripts/migrate_170_180.py b/odoo_module_migrate/migration_scripts/migrate_170_180.py index 8734fa08..df0d4c97 100644 --- a/odoo_module_migrate/migration_scripts/migrate_170_180.py +++ b/odoo_module_migrate/migration_scripts/migrate_170_180.py @@ -100,9 +100,42 @@ def replace_user_has_groups( logger.error(f"Error processing file {file}: {str(e)}") +def replace_slugify( + logger, module_path, module_name, manifest_path, migration_steps, tools +): + files_to_process = tools.get_files(module_path, (".py")) + + for file in files_to_process: + try: + content = tools._read_content(file) + content = re.sub( + r"from\s+odoo\.addons\.http_routing\.models\.ir_http\s+import\s+slugify\b.*\n", + "", + content, + ) + # process in controller (*.py) file are using request + has_request = "request" in content + if has_request: + content = re.sub( + r"""(?