Skip to content

Commit 510359c

Browse files
committed
[IMP] replace editable attribute on list view
1 parent 38e7a02 commit 510359c

File tree

7 files changed

+59
-0
lines changed

7 files changed

+59
-0
lines changed

odoo_module_migrate/migration_scripts/migrate_170_180.py

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

102102

103+
def replace_editable_attribute(
104+
logger, module_path, module_name, manifest_path, migration_steps, tools
105+
):
106+
files_to_process = tools.get_files(module_path, (".xml", ".js", ".py"))
107+
replaces = {
108+
'editable="1"': 'editable="bottom"',
109+
"editable='1'": 'editable="bottom"',
110+
r'<attribute\s+name=["\']editable["\']>1</attribute>': '<attribute name="editable">bottom</attribute>',
111+
}
112+
for file in files_to_process:
113+
try:
114+
tools._replace_in_file(
115+
file,
116+
replaces,
117+
log_message=f"""Replace editable="1" by "bottom" in file: {file}""",
118+
)
119+
except Exception as e:
120+
logger.error(f"Error processing file {file}: {str(e)}")
121+
122+
103123
class MigrationScript(BaseMigrationScript):
104124
_GLOBAL_FUNCTIONS = [
105125
replace_tree_with_list_in_views,
106126
replace_chatter_blocks,
107127
replace_user_has_groups,
128+
replace_editable_attribute,
108129
]

tests/data_result/module_170_180/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
],
1111
'data': [
1212
'views/res_partner.xml',
13+
'views/product_template_view.xml',
1314
],
1415
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
4+
<record id="view_product_template_list_custom" model="ir.ui.view">
5+
<field name="name">product.template.list.custom</field>
6+
<field name="model">product.template</field>
7+
<field name="arch" type="xml">
8+
<list editable="bottom">
9+
<field name="name"/>
10+
<field name="active"/>
11+
</list>
12+
</field>
13+
</record>
14+
15+
</odoo>

tests/data_result/module_170_180/views/res_partner.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<list position="inside">
99
<field name="test_field_1"/>
1010
</list>
11+
<list position="attribute">
12+
<attribute name="editable">bottom</attribute>
13+
</list>
1114
</field>
1215
</record>
1316

tests/data_template/module_170/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
],
1111
'data': [
1212
'views/res_partner.xml',
13+
'views/product_template_view.xml',
1314
],
1415
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
4+
<record id="view_product_template_list_custom" model="ir.ui.view">
5+
<field name="name">product.template.list.custom</field>
6+
<field name="model">product.template</field>
7+
<field name="arch" type="xml">
8+
<list editable="1">
9+
<field name="name"/>
10+
<field name="active"/>
11+
</list>
12+
</field>
13+
</record>
14+
15+
</odoo>

tests/data_template/module_170/views/res_partner.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<tree position="inside">
99
<field name="test_field_1"/>
1010
</tree>
11+
<tree position="attribute">
12+
<attribute name="editable">1</attribute>
13+
</tree>
1114
</field>
1215
</record>
1316

0 commit comments

Comments
 (0)