Skip to content

[ADD] odoo_module_migrate: Deprecated kanban-box-card-menu #119

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

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 @@ -84,6 +84,26 @@ def replace_chatter_self_closing(match):
logger.error(f"Error processing file {file}: {str(e)}")


def replace_deprecated_kanban_box_card_menu(
logger, module_path, module_name, manifest_path, migration_steps, tools
):
files_to_process = tools.get_files(module_path, (".xml", ".js", ".py"))
replaces = {
"kanban-card": "card",
"kanban-box": "card",
"kanban-menu": "menu",
}
for file in files_to_process:
try:
tools._replace_in_file(
file,
replaces,
log_message=f"""Replace kanban-card and kanban-box with card, also change kanban-menu with menu" in file: {file}""",
)
except Exception as e:
logger.error(f"Error processing file {file}: {str(e)}")


def replace_user_has_groups(
logger, module_path, module_name, manifest_path, migration_steps, tools
):
Expand All @@ -102,6 +122,7 @@ def replace_user_has_groups(

class MigrationScript(BaseMigrationScript):
_GLOBAL_FUNCTIONS = [
replace_deprecated_kanban_box_card_menu,
replace_tree_with_list_in_views,
replace_chatter_blocks,
replace_user_has_groups,
Expand Down
40 changes: 40 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 @@ -62,4 +62,44 @@
<chatter/>
</field>
</record>

<record id="res_partner_view_kanban" model="ir.ui.view">
<field name="name">res.partner.view.kanban</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<kanban>
<field name="id"/>
<field name="image_1920"/>
<templates>
<t t-name='card'>
<img t-att-src='kanban_image("res.partner","image_1920",record.id.raw_value)'
alt='Image' class='o_image_64_max'/>
<strong class='o_kanban_record_title ms-2'><field name='name'/></strong>
</t>
<t t-name="menu">
<a t-if="widget.deletable" role="menuitem" type="delete" class="dropdown-item">Delete</a>
</t>
</templates>
</kanban>
</field>
</record>

<record id="res_partner_view_kanban2" model="ir.ui.view">
<field name="name">res.partner.view.kanban</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<kanban>
<field name="id"/>
<field name="image_1920"/>
<templates>
<t t-name='card'>
<img t-att-src='kanban_image("res.partner","image_1920",record.id.raw_value)'
alt='Image' class='o_image_64_max'/>
<strong class='o_kanban_record_title ms-2'><field name='name'/></strong>
</t>
</templates>
</kanban>
</field>
</record>

</odoo>
40 changes: 40 additions & 0 deletions tests/data_template/module_170/views/res_partner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,44 @@
</div>
</field>
</record>

<record id="res_partner_view_kanban" model="ir.ui.view">
<field name="name">res.partner.view.kanban</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<kanban>
<field name="id"/>
<field name="image_1920"/>
<templates>
<t t-name='kanban-card'>
<img t-att-src='kanban_image("res.partner","image_1920",record.id.raw_value)'
alt='Image' class='o_image_64_max'/>
<strong class='o_kanban_record_title ms-2'><field name='name'/></strong>
</t>
<t t-name="kanban-menu">
<a t-if="widget.deletable" role="menuitem" type="delete" class="dropdown-item">Delete</a>
</t>
</templates>
</kanban>
</field>
</record>

<record id="res_partner_view_kanban2" model="ir.ui.view">
<field name="name">res.partner.view.kanban</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<kanban>
<field name="id"/>
<field name="image_1920"/>
<templates>
<t t-name='kanban-box'>
<img t-att-src='kanban_image("res.partner","image_1920",record.id.raw_value)'
alt='Image' class='o_image_64_max'/>
<strong class='o_kanban_record_title ms-2'><field name='name'/></strong>
</t>
</templates>
</kanban>
</field>
</record>

</odoo>
Loading