Skip to content

Commit 7c8f3b8

Browse files
authored
Merge pull request #191 from OpenSPP/fix/992-studio-event-data-button
fix(spp_studio_events): clarify Create Event step 1 for Studio types (#992)
2 parents c57bd36 + e0ff3c6 commit 7c8f3b8

8 files changed

Lines changed: 163 additions & 3 deletions

File tree

spp_studio_events/README.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ Dependencies
137137
Changelog
138138
=========
139139

140+
19.0.2.0.2
141+
~~~~~~~~~~
142+
143+
- fix(views): the basic Create Event wizard's step 1 is now
144+
self-explanatory for Studio-backed event types. The misleading raw
145+
JSON field is hidden; an info banner announces the next stage; the
146+
"Create Event" button is renamed "Next" so users know there's a second
147+
step where the structured fields appear. Non-Studio event types keep
148+
the original step-1 UI unchanged. Backed by a new computed
149+
``is_studio_event_type`` boolean on ``spp.create.event.wizard``.
150+
151+
19.0.2.0.1
152+
~~~~~~~~~~
153+
154+
- fix(views): clicking the **Events** smart button on a Studio Event
155+
Type form no longer crashes with ``View types not defined tree``.
156+
``action_view_events`` returned ``view_mode="tree,form"``, but Odoo 19
157+
renamed ``tree`` to ``list``; switched to ``view_mode="list,form"``.
158+
140159
19.0.2.0.0
141160
~~~~~~~~~~
142161

spp_studio_events/__manifest__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pylint: disable-next=pointless-statement
22
{
33
"name": "OpenSPP Studio - Events",
4-
"version": "19.0.2.0.0",
4+
"version": "19.0.2.0.2",
55
"category": "OpenSPP/Configuration",
66
"summary": "No-code event type designer for data collection",
77
"author": "OpenSPP.org",
@@ -22,6 +22,7 @@
2222
# Wizards
2323
"wizard/event_type_wizard_views.xml",
2424
"wizard/event_data_entry_wizard_views.xml",
25+
"wizard/create_event_wizard_views.xml",
2526
# Data
2627
"data/event_field_templates.xml",
2728
],

spp_studio_events/models/studio_event_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ def action_view_events(self):
723723
"type": "ir.actions.act_window",
724724
"name": _("Events: %(name)s", name=self.name),
725725
"res_model": "spp.event.data",
726-
"view_mode": "tree,form",
726+
"view_mode": "list,form",
727727
"domain": [("event_type_id", "=", self.spp_event_type_id.id)],
728728
"context": {"default_event_type_id": self.spp_event_type_id.id},
729729
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
### 19.0.2.0.2
2+
3+
- fix(views): the basic Create Event wizard's step 1 is now self-explanatory for Studio-backed event types. The misleading raw JSON field is hidden; an info banner announces the next stage; the "Create Event" button is renamed "Next" so users know there's a second step where the structured fields appear. Non-Studio event types keep the original step-1 UI unchanged. Backed by a new computed `is_studio_event_type` boolean on `spp.create.event.wizard`.
4+
5+
### 19.0.2.0.1
6+
7+
- fix(views): clicking the **Events** smart button on a Studio Event Type form no longer crashes with `View types not defined tree`. `action_view_events` returned `view_mode="tree,form"`, but Odoo 19 renamed `tree` to `list`; switched to `view_mode="list,form"`.
8+
19
### 19.0.2.0.0
210

311
- Initial migration to OpenSPP2

spp_studio_events/static/description/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,27 @@ <h2><a class="toc-backref" href="#toc-entry-1">Changelog</a></h2>
516516
</div>
517517
</div>
518518
<div class="section" id="section-1">
519+
<h1>19.0.2.0.2</h1>
520+
<ul class="simple">
521+
<li>fix(views): the basic Create Event wizard’s step 1 is now
522+
self-explanatory for Studio-backed event types. The misleading raw
523+
JSON field is hidden; an info banner announces the next stage; the
524+
“Create Event” button is renamed “Next” so users know there’s a second
525+
step where the structured fields appear. Non-Studio event types keep
526+
the original step-1 UI unchanged. Backed by a new computed
527+
<tt class="docutils literal">is_studio_event_type</tt> boolean on <tt class="docutils literal">spp.create.event.wizard</tt>.</li>
528+
</ul>
529+
</div>
530+
<div class="section" id="section-2">
531+
<h1>19.0.2.0.1</h1>
532+
<ul class="simple">
533+
<li>fix(views): clicking the <strong>Events</strong> smart button on a Studio Event
534+
Type form no longer crashes with <tt class="docutils literal">View types not defined tree</tt>.
535+
<tt class="docutils literal">action_view_events</tt> returned <tt class="docutils literal"><span class="pre">view_mode=&quot;tree,form&quot;</span></tt>, but Odoo 19
536+
renamed <tt class="docutils literal">tree</tt> to <tt class="docutils literal">list</tt>; switched to <tt class="docutils literal"><span class="pre">view_mode=&quot;list,form&quot;</span></tt>.</li>
537+
</ul>
538+
</div>
539+
<div class="section" id="section-3">
519540
<h1>19.0.2.0.0</h1>
520541
<ul class="simple">
521542
<li>Initial migration to OpenSPP2</li>

spp_studio_events/tests/test_create_event_wizard_integration.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,26 @@ def test_studio_wizard_has_dynamic_fields(self):
156156
field_name = f"x_evt_{test_field.technical_name}"
157157
self.assertIn(field_name, studio_wizard._fields)
158158

159+
def test_is_studio_event_type_flag(self):
160+
"""Test the is_studio_event_type computed field that drives step-1 UX."""
161+
# Studio-backed event type → flag is True
162+
wizard = self.env["spp.create.event.wizard"].create(
163+
{
164+
"partner_id": self.registrant.id,
165+
"event_type_id": self.event_type.id,
166+
"collection_date": date.today(),
167+
}
168+
)
169+
self.assertTrue(wizard.is_studio_event_type)
170+
171+
# Switching to a non-Studio event type → flag flips to False
172+
wizard.event_type_id = self.regular_event_type
173+
self.assertFalse(wizard.is_studio_event_type)
174+
175+
# Clearing the event type → flag is False
176+
wizard.event_type_id = False
177+
self.assertFalse(wizard.is_studio_event_type)
178+
159179
def test_inactive_studio_type_does_not_redirect(self):
160180
"""Test that inactive Studio types don't trigger redirect."""
161181
# Deactivate the Studio event type

spp_studio_events/wizard/create_event_wizard.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44

5-
from odoo import _, models
5+
from odoo import _, api, fields, models
66

77
_logger = logging.getLogger(__name__)
88

@@ -12,6 +12,22 @@ class SPPCreateEventWizardStudioExtension(models.TransientModel):
1212

1313
_inherit = "spp.create.event.wizard"
1414

15+
is_studio_event_type = fields.Boolean(
16+
compute="_compute_is_studio_event_type",
17+
help=(
18+
"True when the selected event type was created via Studio and "
19+
"renders structured fields in the next stage. Drives the basic "
20+
"wizard's UX: hides the misleading raw JSON input, shows an "
21+
"info banner, and renames the submit button to 'Next' so users "
22+
"know there's a second step coming."
23+
),
24+
)
25+
26+
@api.depends("event_type_id")
27+
def _compute_is_studio_event_type(self):
28+
for rec in self:
29+
rec.is_studio_event_type = bool(rec.event_type_id and rec.event_type_id._get_active_studio_event_type())
30+
1531
def create_event(self):
1632
"""Override to redirect to Studio wizard if applicable.
1733
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<!--
4+
Inherit the basic Create Event wizard form to make step 1 of the
5+
Studio flow self-explanatory:
6+
7+
- Hide the raw JSON `event_data` field for Studio event types
8+
(it's misleading since the structured fields render in the
9+
next stage, not this one).
10+
- Insert an info banner that announces the next stage.
11+
- Replace the "Create Event" button with a "Next" button when the
12+
selected event type is Studio-backed; non-Studio types keep
13+
"Create Event" because for them this *is* the only stage.
14+
15+
See OP#992.
16+
-->
17+
<record id="view_spp_create_event_wizard_form_studio" model="ir.ui.view">
18+
<field name="name">spp.create.event.wizard.form.studio</field>
19+
<field name="model">spp.create.event.wizard</field>
20+
<field
21+
name="inherit_id"
22+
ref="spp_event_data.view_spp_create_event_wizard_form"
23+
/>
24+
<field name="arch" type="xml">
25+
<!-- Make the Studio flag readable from the view's evaluation
26+
context so the conditional attributes below work. -->
27+
<xpath expr="//field[@name='partner_id']" position="before">
28+
<field name="is_studio_event_type" invisible="1" />
29+
</xpath>
30+
31+
<!-- Info banner at the top of the sheet — full-width, only
32+
visible for Studio-backed event types. Placed before the
33+
first group so it renders as a banner above the form
34+
fields rather than as a column-neighbor of the (now
35+
hidden) JSON group. -->
36+
<xpath expr="//sheet/group[1]" position="before">
37+
<div
38+
class="alert alert-info"
39+
role="alert"
40+
invisible="not is_studio_event_type"
41+
>
42+
This event type uses <strong>structured fields</strong>.
43+
Click <strong>Next</strong> to enter them — you'll be
44+
moved to the second stage where each defined field
45+
appears as its own input.
46+
</div>
47+
</xpath>
48+
49+
<!-- Hide the raw JSON group when the event type is Studio-backed. -->
50+
<xpath expr="//field[@name='event_data']/.." position="attributes">
51+
<attribute
52+
name="invisible"
53+
>not event_type_id or is_studio_event_type</attribute>
54+
</xpath>
55+
56+
<!-- Hide the original "Create Event" button when Studio. -->
57+
<xpath expr="//footer/button[@name='create_event']" position="attributes">
58+
<attribute
59+
name="invisible"
60+
>not event_type_id or is_studio_event_type</attribute>
61+
</xpath>
62+
63+
<!-- Add a "Next" button (same backing method) for Studio types. -->
64+
<xpath expr="//footer/button[@name='create_event']" position="after">
65+
<button
66+
name="create_event"
67+
string="Next"
68+
type="object"
69+
class="oe_highlight"
70+
invisible="not is_studio_event_type"
71+
/>
72+
</xpath>
73+
</field>
74+
</record>
75+
</odoo>

0 commit comments

Comments
 (0)