Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions odoo_module_migrate/migration_scripts/migrate_170_180.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,32 @@ def replace_ustr(
logger.error(f"Error processing file {file}: {str(e)}")


def replace_editable_attribute(
logger, module_path, module_name, manifest_path, migration_steps, tools
):
files_to_process = tools.get_files(module_path, (".xml", ".js", ".py"))
replaces = {
'editable="1"': 'editable="bottom"',
"editable='1'": 'editable="bottom"',
r'<attribute\s+name=["\']editable["\']>1</attribute>': '<attribute name="editable">bottom</attribute>',
}
for file in files_to_process:
try:
tools._replace_in_file(
file,
replaces,
log_message=f"""Replace editable="1" by "bottom" in file: {file}""",
)
except Exception as e:
logger.error(f"Error processing file {file}: {str(e)}")


class MigrationScript(BaseMigrationScript):
_GLOBAL_FUNCTIONS = [
replace_unaccent_parameter,
replace_tree_with_list_in_views,
replace_chatter_blocks,
replace_user_has_groups,
replace_ustr,
replace_editable_attribute,
]
1 change: 1 addition & 0 deletions tests/data_result/module_170_180/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
],
'data': [
'views/res_partner.xml',
'views/product_template_view.xml',
],
}
15 changes: 15 additions & 0 deletions tests/data_result/module_170_180/views/product_template_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_product_template_list_custom" model="ir.ui.view">
<field name="name">product.template.list.custom</field>
<field name="model">product.template</field>
<field name="arch" type="xml">
<list editable="bottom">
<field name="name"/>
<field name="active"/>
</list>
</field>
</record>

</odoo>
3 changes: 3 additions & 0 deletions tests/data_result/module_170_180/views/res_partner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<field name="test_field_1"/>
<field name="active" widget="boolean_toggle"/>
</list>
<list position="attribute">
<attribute name="editable">bottom</attribute>
</list>
</field>
</record>

Expand Down
1 change: 1 addition & 0 deletions tests/data_template/module_170/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
],
'data': [
'views/res_partner.xml',
'views/product_template_view.xml',
],
}
15 changes: 15 additions & 0 deletions tests/data_template/module_170/views/product_template_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_product_template_list_custom" model="ir.ui.view">
<field name="name">product.template.list.custom</field>
<field name="model">product.template</field>
<field name="arch" type="xml">
<list editable="1">
<field name="name"/>
<field name="active"/>
</list>
</field>
</record>

</odoo>
3 changes: 3 additions & 0 deletions tests/data_template/module_170/views/res_partner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<field name="test_field_1"/>
<field name="active" widget='toggle_button'/>
</tree>
<tree position="attribute">
<attribute name="editable">1</attribute>
</tree>
</field>
</record>

Expand Down