Skip to content

Commit bc0cfe5

Browse files
authored
Merge pull request #207 from OpenSPP/fix/1001-grm-tickets-smart-button
fix(spp_grm,spp_grm_registry): deduplicate Tickets smart button + fix caption/view_mode (#1000, #1001)
2 parents 6991217 + 2ae7ae0 commit bc0cfe5

4 files changed

Lines changed: 35 additions & 36 deletions

File tree

spp_grm/views/res_partner_views.xml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,6 @@
2222
</field>
2323
</record>
2424

25-
<!-- Group Registrant form -->
26-
<record id="view_groups_form_inherit_spp_grm" model="ir.ui.view">
27-
<field name="name">view_groups_form_inherit_spp_grm</field>
28-
<field name="model">res.partner</field>
29-
<field name="inherit_id" ref="spp_registry.view_individuals_form" />
30-
<field name="arch" type="xml">
31-
<xpath expr="//div[@name='button_box']" position="inside">
32-
<button
33-
context="{'search_default_open': True, 'default_partner_id': id}"
34-
name="action_view_grm_tickets"
35-
type="object"
36-
class="oe_stat_button"
37-
icon="fa-life-ring"
38-
>
39-
<field invisible="True" name="grm_ticket_active_count" />
40-
<field invisible="True" name="grm_ticket_count" />
41-
<field name="grm_ticket_count_string" widget="statinfo" />
42-
</button>
43-
</xpath>
44-
</field>
45-
</record>
46-
4725
<!-- Default partner form -->
4826
<record id="view_partner_form" model="ir.ui.view">
4927
<field name="name">view_partner_form</field>

spp_grm_registry/models/res_partner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def action_view_grm_registrant_tickets(self):
5454
"type": "ir.actions.act_window",
5555
"name": "GRM Tickets (Registrant)",
5656
"res_model": "spp.grm.ticket",
57-
"view_mode": "tree,form,kanban",
57+
"view_mode": "list,form,kanban",
5858
"domain": [("registrant_id", "=", self.id)],
5959
"context": {"default_registrant_id": self.id},
6060
}
@@ -66,7 +66,7 @@ def action_view_grm_household_tickets(self):
6666
"type": "ir.actions.act_window",
6767
"name": "GRM Tickets (Household)",
6868
"res_model": "spp.grm.ticket",
69-
"view_mode": "tree,form,kanban",
69+
"view_mode": "list,form,kanban",
7070
"domain": [("household_id", "=", self.id)],
7171
"context": {"default_household_id": self.id},
7272
}

spp_grm_registry/tests/test_res_partner.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,11 @@ def test_action_view_registrant_tickets_context(self):
226226
self.assertEqual(action["context"]["default_registrant_id"], self.registrant.id)
227227

228228
def test_action_view_registrant_tickets_view_mode(self):
229-
"""action_view_grm_registrant_tickets exposes tree, form, and kanban views."""
229+
"""action_view_grm_registrant_tickets exposes list, form, and kanban views."""
230230
action = self.registrant.action_view_grm_registrant_tickets()
231-
for mode in ("tree", "form", "kanban"):
231+
for mode in ("list", "form", "kanban"):
232232
self.assertIn(mode, action["view_mode"])
233+
self.assertNotIn("tree", action["view_mode"])
233234

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

258259
def test_action_view_household_tickets_view_mode(self):
259-
"""action_view_grm_household_tickets exposes tree, form, and kanban views."""
260+
"""action_view_grm_household_tickets exposes list, form, and kanban views."""
260261
action = self.household.action_view_grm_household_tickets()
261-
for mode in ("tree", "form", "kanban"):
262+
for mode in ("list", "form", "kanban"):
262263
self.assertIn(mode, action["view_mode"])
264+
self.assertNotIn("tree", action["view_mode"])

spp_grm_registry/views/res_partner_views.xml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
icon="fa-ticket"
1616
invisible="is_group or not is_registrant"
1717
>
18-
<div class="o_stat_info">
19-
<field name="grm_registrant_ticket_count" widget="statinfo" />
20-
<span class="o_stat_text">GRM Tickets</span>
21-
</div>
18+
<field
19+
name="grm_registrant_ticket_count"
20+
widget="statinfo"
21+
string="GRM Tickets"
22+
/>
2223
</button>
2324
</xpath>
2425

@@ -77,10 +78,11 @@
7778
icon="fa-ticket"
7879
invisible="not is_group or not is_registrant"
7980
>
80-
<div class="o_stat_info">
81-
<field name="grm_household_ticket_count" widget="statinfo" />
82-
<span class="o_stat_text">GRM Tickets</span>
83-
</div>
81+
<field
82+
name="grm_household_ticket_count"
83+
widget="statinfo"
84+
string="GRM Tickets"
85+
/>
8486
</button>
8587
</xpath>
8688

@@ -120,4 +122,21 @@
120122
</xpath>
121123
</field>
122124
</record>
125+
126+
<!--
127+
OP#1000: when spp_grm_registry is installed, its registrant + household
128+
buttons replace the legacy single-button view from spp_grm. Hide the
129+
legacy button on registrant forms so only the registry-specific buttons
130+
remain. spp_grm's view on the base partner form (for plain partners)
131+
is untouched.
132+
-->
133+
<record id="view_res_partner_form_hide_legacy_grm_button" model="ir.ui.view">
134+
<field name="name">res.partner.form.hide-legacy-grm-button</field>
135+
<field name="model">res.partner</field>
136+
<field name="inherit_id" ref="spp_grm.view_individuals_form_inherit_spp_grm" />
137+
<field name="priority">99</field>
138+
<field name="arch" type="xml">
139+
<button name="action_view_grm_tickets" position="replace" />
140+
</field>
141+
</record>
123142
</odoo>

0 commit comments

Comments
 (0)