Skip to content
Merged
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
22 changes: 0 additions & 22 deletions spp_grm/views/res_partner_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@
</field>
</record>

<!-- Group Registrant form -->
<record id="view_groups_form_inherit_spp_grm" model="ir.ui.view">
<field name="name">view_groups_form_inherit_spp_grm</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="spp_registry.view_individuals_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button
context="{'search_default_open': True, 'default_partner_id': id}"
name="action_view_grm_tickets"
type="object"
class="oe_stat_button"
icon="fa-life-ring"
>
<field invisible="True" name="grm_ticket_active_count" />
<field invisible="True" name="grm_ticket_count" />
<field name="grm_ticket_count_string" widget="statinfo" />
</button>
</xpath>
</field>
</record>

<!-- Default partner form -->
<record id="view_partner_form" model="ir.ui.view">
<field name="name">view_partner_form</field>
Expand Down
4 changes: 2 additions & 2 deletions spp_grm_registry/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def action_view_grm_registrant_tickets(self):
"type": "ir.actions.act_window",
"name": "GRM Tickets (Registrant)",
"res_model": "spp.grm.ticket",
"view_mode": "tree,form,kanban",
"view_mode": "list,form,kanban",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In Odoo 17+, the tree view type has been renamed to list. Using the correct view_mode prevents potential client-side errors and aligns with modern Odoo conventions.

References
  1. In Odoo 17+, the 'tree' view type has been renamed to 'list'. (link)

"domain": [("registrant_id", "=", self.id)],
"context": {"default_registrant_id": self.id},
}
Expand All @@ -66,7 +66,7 @@ def action_view_grm_household_tickets(self):
"type": "ir.actions.act_window",
"name": "GRM Tickets (Household)",
"res_model": "spp.grm.ticket",
"view_mode": "tree,form,kanban",
"view_mode": "list,form,kanban",
"domain": [("household_id", "=", self.id)],
"context": {"default_household_id": self.id},
}
10 changes: 6 additions & 4 deletions spp_grm_registry/tests/test_res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,11 @@ def test_action_view_registrant_tickets_context(self):
self.assertEqual(action["context"]["default_registrant_id"], self.registrant.id)

def test_action_view_registrant_tickets_view_mode(self):
"""action_view_grm_registrant_tickets exposes tree, form, and kanban views."""
"""action_view_grm_registrant_tickets exposes list, form, and kanban views."""
action = self.registrant.action_view_grm_registrant_tickets()
for mode in ("tree", "form", "kanban"):
for mode in ("list", "form", "kanban"):
self.assertIn(mode, action["view_mode"])
self.assertNotIn("tree", action["view_mode"])

# ------------------------------------------------------------------ #
# action_view_grm_household_tickets #
Expand All @@ -256,7 +257,8 @@ def test_action_view_household_tickets_context(self):
self.assertEqual(action["context"]["default_household_id"], self.household.id)

def test_action_view_household_tickets_view_mode(self):
"""action_view_grm_household_tickets exposes tree, form, and kanban views."""
"""action_view_grm_household_tickets exposes list, form, and kanban views."""
action = self.household.action_view_grm_household_tickets()
for mode in ("tree", "form", "kanban"):
for mode in ("list", "form", "kanban"):
self.assertIn(mode, action["view_mode"])
self.assertNotIn("tree", action["view_mode"])
35 changes: 27 additions & 8 deletions spp_grm_registry/views/res_partner_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
icon="fa-ticket"
invisible="is_group or not is_registrant"
>
<div class="o_stat_info">
<field name="grm_registrant_ticket_count" widget="statinfo" />
<span class="o_stat_text">GRM Tickets</span>
</div>
<field
name="grm_registrant_ticket_count"
widget="statinfo"
string="GRM Tickets"
/>
Comment on lines +18 to +22
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the string attribute directly on the field with widget="statinfo" is the idiomatic way to define smart button labels in Odoo 17+. This avoids the double-caption issue caused by combining the widget's automatic label with a manual <span>.

References
  1. In Odoo 17+, use the 'string' attribute on the 'field' with 'widget="statinfo"' for smart buttons. (link)

</button>
</xpath>

Expand Down Expand Up @@ -77,10 +78,11 @@
icon="fa-ticket"
invisible="not is_group or not is_registrant"
>
<div class="o_stat_info">
<field name="grm_household_ticket_count" widget="statinfo" />
<span class="o_stat_text">GRM Tickets</span>
</div>
<field
name="grm_household_ticket_count"
widget="statinfo"
string="GRM Tickets"
/>
</button>
</xpath>

Expand Down Expand Up @@ -120,4 +122,21 @@
</xpath>
</field>
</record>

<!--
OP#1000: when spp_grm_registry is installed, its registrant + household
buttons replace the legacy single-button view from spp_grm. Hide the
legacy button on registrant forms so only the registry-specific buttons
remain. spp_grm's view on the base partner form (for plain partners)
is untouched.
-->
<record id="view_res_partner_form_hide_legacy_grm_button" model="ir.ui.view">
<field name="name">res.partner.form.hide-legacy-grm-button</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="spp_grm.view_individuals_form_inherit_spp_grm" />
<field name="priority">99</field>
<field name="arch" type="xml">
<button name="action_view_grm_tickets" position="replace" />
</field>
</record>
</odoo>
Loading