Skip to content

Commit 9183915

Browse files
committed
[IMP] automatically remove @odoo-module from js assets
1 parent 38e7a02 commit 9183915

File tree

7 files changed

+50
-0
lines changed

7 files changed

+50
-0
lines changed

odoo_module_migrate/migration_scripts/migrate_170_180.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,34 @@ def replace_user_has_groups(
100100
logger.error(f"Error processing file {file}: {str(e)}")
101101

102102

103+
def replace_odoo_module_from_js_assets(
104+
logger, module_path, module_name, manifest_path, migration_steps, tools
105+
):
106+
files_to_process = tools.get_files(module_path, (".js",))
107+
replaces = {
108+
r"/\*\*\s*@odoo-module\s*\*\*/\s*\n?": "",
109+
r"/\*\s*@odoo-module\s*\*/\s*\n?": "",
110+
r"/\*\*\s*@odoo-module\s*\*/\s*\n?": "",
111+
r"/\*\s*@odoo-module\s*\*\*/\s*\n?": "",
112+
}
113+
for file in files_to_process:
114+
file_str = str(file)
115+
if not ("/static/src" in file_str or "/static/tests" in file_str):
116+
continue
117+
try:
118+
tools._replace_in_file(
119+
file,
120+
replaces,
121+
log_message=f"Remove @odoo-module from js assets in file: {file}",
122+
)
123+
except Exception as e:
124+
logger.error(f"Error processing file {file}: {str(e)}")
125+
126+
103127
class MigrationScript(BaseMigrationScript):
104128
_GLOBAL_FUNCTIONS = [
105129
replace_tree_with_list_in_views,
106130
replace_chatter_blocks,
107131
replace_user_has_groups,
132+
replace_odoo_module_from_js_assets,
108133
]

tests/data_result/module_170_180/__manifest__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@
1111
'data': [
1212
'views/res_partner.xml',
1313
],
14+
'assets': {
15+
'web.assets_backend': [
16+
'module_170/static/src/js/main.js',
17+
],
18+
},
1419
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @odoo-module **/
2+
3+
// example js file include tag @odoo-module but not process this file
4+
// because it does not in static/src or static/tests
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// example js file include tag @odoo-module

tests/data_template/module_170/__manifest__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@
1111
'data': [
1212
'views/res_partner.xml',
1313
],
14+
'assets': {
15+
'web.assets_backend': [
16+
'module_170/static/src/js/main.js',
17+
],
18+
},
1419
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @odoo-module **/
2+
3+
// example js file include tag @odoo-module but not process this file
4+
// because it does not in static/src or static/tests
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** @odoo-module **/
2+
/* @odoo-module */
3+
/** @odoo-module */
4+
/* @odoo-module **/
5+
6+
// example js file include tag @odoo-module

0 commit comments

Comments
 (0)