Skip to content

Commit eef0c32

Browse files
committed
[IMP] replace editable attribute on list view
1 parent aecc671 commit eef0c32

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
@@ -149,11 +149,32 @@ def replace_ustr(
149149
logger.error(f"Error processing file {file}: {str(e)}")
150150

151151

152+
def replace_editable_attribute(
153+
logger, module_path, module_name, manifest_path, migration_steps, tools
154+
):
155+
files_to_process = tools.get_files(module_path, (".xml", ".js", ".py"))
156+
replaces = {
157+
'editable="1"': 'editable="bottom"',
158+
"editable='1'": 'editable="bottom"',
159+
r'<attribute\s+name=["\']editable["\']>1</attribute>': '<attribute name="editable">bottom</attribute>',
160+
}
161+
for file in files_to_process:
162+
try:
163+
tools._replace_in_file(
164+
file,
165+
replaces,
166+
log_message=f"""Replace editable="1" by "bottom" in file: {file}""",
167+
)
168+
except Exception as e:
169+
logger.error(f"Error processing file {file}: {str(e)}")
170+
171+
152172
class MigrationScript(BaseMigrationScript):
153173
_GLOBAL_FUNCTIONS = [
154174
replace_unaccent_parameter,
155175
replace_tree_with_list_in_views,
156176
replace_chatter_blocks,
157177
replace_user_has_groups,
158178
replace_ustr,
179+
replace_editable_attribute,
159180
]

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
@@ -9,6 +9,9 @@
99
<field name="test_field_1"/>
1010
<field name="active" widget="boolean_toggle"/>
1111
</list>
12+
<list position="attribute">
13+
<attribute name="editable">bottom</attribute>
14+
</list>
1215
</field>
1316
</record>
1417

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
@@ -9,6 +9,9 @@
99
<field name="test_field_1"/>
1010
<field name="active" widget='toggle_button'/>
1111
</tree>
12+
<tree position="attribute">
13+
<attribute name="editable">1</attribute>
14+
</tree>
1215
</field>
1316
</record>
1417

0 commit comments

Comments
 (0)