Skip to content

Commit 996c297

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

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

odoo_module_migrate/migration_scripts/migrate_170_180.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,31 @@ 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+
try:
115+
tools._replace_in_file(
116+
file,
117+
replaces,
118+
log_message=f"Remove @odoo-module from js assets in file: {file}",
119+
)
120+
except Exception as e:
121+
logger.error(f"Error processing file {file}: {str(e)}")
122+
123+
103124
class MigrationScript(BaseMigrationScript):
104125
_GLOBAL_FUNCTIONS = [
105126
replace_tree_with_list_in_views,
106127
replace_chatter_blocks,
107128
replace_user_has_groups,
129+
replace_odoo_module_from_js_assets,
108130
]

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: 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: 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)