Skip to content
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
19 changes: 19 additions & 0 deletions spp_studio_events/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,25 @@ Dependencies
Changelog
=========

19.0.2.0.2
~~~~~~~~~~

- 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``.

19.0.2.0.1
~~~~~~~~~~

- 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"``.

19.0.2.0.0
~~~~~~~~~~

Expand Down
3 changes: 2 additions & 1 deletion spp_studio_events/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylint: disable-next=pointless-statement
{
"name": "OpenSPP Studio - Events",
"version": "19.0.2.0.0",
"version": "19.0.2.0.2",
"category": "OpenSPP/Configuration",
"summary": "No-code event type designer for data collection",
"author": "OpenSPP.org",
Expand All @@ -22,6 +22,7 @@
# Wizards
"wizard/event_type_wizard_views.xml",
"wizard/event_data_entry_wizard_views.xml",
"wizard/create_event_wizard_views.xml",
# Data
"data/event_field_templates.xml",
],
Expand Down
2 changes: 1 addition & 1 deletion spp_studio_events/models/studio_event_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def action_view_events(self):
"type": "ir.actions.act_window",
"name": _("Events: %(name)s", name=self.name),
"res_model": "spp.event.data",
"view_mode": "tree,form",
"view_mode": "list,form",
"domain": [("event_type_id", "=", self.spp_event_type_id.id)],
"context": {"default_event_type_id": self.spp_event_type_id.id},
}
Expand Down
8 changes: 8 additions & 0 deletions spp_studio_events/readme/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 19.0.2.0.2

- 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`.

### 19.0.2.0.1

- 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"`.

### 19.0.2.0.0

- Initial migration to OpenSPP2
21 changes: 21 additions & 0 deletions spp_studio_events/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,27 @@ <h2><a class="toc-backref" href="#toc-entry-1">Changelog</a></h2>
</div>
</div>
<div class="section" id="section-1">
<h1>19.0.2.0.2</h1>
<ul class="simple">
<li>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
<tt class="docutils literal">is_studio_event_type</tt> boolean on <tt class="docutils literal">spp.create.event.wizard</tt>.</li>
</ul>
</div>
<div class="section" id="section-2">
<h1>19.0.2.0.1</h1>
<ul class="simple">
<li>fix(views): clicking the <strong>Events</strong> smart button on a Studio Event
Type form no longer crashes with <tt class="docutils literal">View types not defined tree</tt>.
<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
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>
</ul>
</div>
<div class="section" id="section-3">
<h1>19.0.2.0.0</h1>
<ul class="simple">
<li>Initial migration to OpenSPP2</li>
Expand Down
20 changes: 20 additions & 0 deletions spp_studio_events/tests/test_create_event_wizard_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,26 @@ def test_studio_wizard_has_dynamic_fields(self):
field_name = f"x_evt_{test_field.technical_name}"
self.assertIn(field_name, studio_wizard._fields)

def test_is_studio_event_type_flag(self):
"""Test the is_studio_event_type computed field that drives step-1 UX."""
# Studio-backed event type → flag is True
wizard = self.env["spp.create.event.wizard"].create(
{
"partner_id": self.registrant.id,
"event_type_id": self.event_type.id,
"collection_date": date.today(),
}
)
self.assertTrue(wizard.is_studio_event_type)

# Switching to a non-Studio event type → flag flips to False
wizard.event_type_id = self.regular_event_type
self.assertFalse(wizard.is_studio_event_type)

# Clearing the event type → flag is False
wizard.event_type_id = False
self.assertFalse(wizard.is_studio_event_type)

def test_inactive_studio_type_does_not_redirect(self):
"""Test that inactive Studio types don't trigger redirect."""
# Deactivate the Studio event type
Expand Down
18 changes: 17 additions & 1 deletion spp_studio_events/wizard/create_event_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging

from odoo import _, models
from odoo import _, api, fields, models

_logger = logging.getLogger(__name__)

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

_inherit = "spp.create.event.wizard"

is_studio_event_type = fields.Boolean(
compute="_compute_is_studio_event_type",
help=(
"True when the selected event type was created via Studio and "
"renders structured fields in the next stage. Drives the basic "
"wizard's UX: hides the misleading raw JSON input, shows an "
"info banner, and renames the submit button to 'Next' so users "
"know there's a second step coming."
),
)

@api.depends("event_type_id")
def _compute_is_studio_event_type(self):
for rec in self:
rec.is_studio_event_type = bool(rec.event_type_id and rec.event_type_id._get_active_studio_event_type())

def create_event(self):
"""Override to redirect to Studio wizard if applicable.

Expand Down
75 changes: 75 additions & 0 deletions spp_studio_events/wizard/create_event_wizard_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!--
Inherit the basic Create Event wizard form to make step 1 of the
Studio flow self-explanatory:

- Hide the raw JSON `event_data` field for Studio event types
(it's misleading since the structured fields render in the
next stage, not this one).
- Insert an info banner that announces the next stage.
- Replace the "Create Event" button with a "Next" button when the
selected event type is Studio-backed; non-Studio types keep
"Create Event" because for them this *is* the only stage.

See OP#992.
-->
<record id="view_spp_create_event_wizard_form_studio" model="ir.ui.view">
<field name="name">spp.create.event.wizard.form.studio</field>
<field name="model">spp.create.event.wizard</field>
<field
name="inherit_id"
ref="spp_event_data.view_spp_create_event_wizard_form"
/>
<field name="arch" type="xml">
<!-- Make the Studio flag readable from the view's evaluation
context so the conditional attributes below work. -->
<xpath expr="//field[@name='partner_id']" position="before">
<field name="is_studio_event_type" invisible="1" />
</xpath>

<!-- Info banner at the top of the sheet — full-width, only
visible for Studio-backed event types. Placed before the
first group so it renders as a banner above the form
fields rather than as a column-neighbor of the (now
hidden) JSON group. -->
<xpath expr="//sheet/group[1]" position="before">
<div
class="alert alert-info"
role="alert"
invisible="not is_studio_event_type"
>
This event type uses <strong>structured fields</strong>.
Click <strong>Next</strong> to enter them — you'll be
moved to the second stage where each defined field
appears as its own input.
</div>
</xpath>

<!-- Hide the raw JSON group when the event type is Studio-backed. -->
<xpath expr="//field[@name='event_data']/.." position="attributes">
<attribute
name="invisible"
>not event_type_id or is_studio_event_type</attribute>
</xpath>

<!-- Hide the original "Create Event" button when Studio. -->
<xpath expr="//footer/button[@name='create_event']" position="attributes">
<attribute
name="invisible"
>not event_type_id or is_studio_event_type</attribute>
</xpath>

<!-- Add a "Next" button (same backing method) for Studio types. -->
<xpath expr="//footer/button[@name='create_event']" position="after">
<button
name="create_event"
string="Next"
type="object"
class="oe_highlight"
invisible="not is_studio_event_type"
/>
</xpath>
</field>
</record>
</odoo>
Loading