Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] replace editable attribute on list view #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 @@ -100,9 +100,30 @@ def replace_user_has_groups(
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_tree_with_list_in_views,
replace_chatter_blocks,
replace_user_has_groups,
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 @@ -8,6 +8,9 @@
<list position="inside">
<field name="test_field_1"/>
</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 @@ -8,6 +8,9 @@
<tree position="inside">
<field name="test_field_1"/>
</tree>
<tree position="attribute">
<attribute name="editable">1</attribute>
</tree>
</field>
</record>

Expand Down
Loading