Skip to content

Commit e3eae92

Browse files
authored
Merge pull request #202 from OpenSPP/fix/hide-pager-on-single-record
fix(spp_change_request_v2,spp_base_common): route post-submit CRs through stage review form + hide single-record pager (#920)
2 parents b106560 + f1bab03 commit e3eae92

10 files changed

Lines changed: 136 additions & 26 deletions

File tree

spp_base_common/__manifest__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "OpenSPP Base (Common)",
77
"category": "OpenSPP/Core",
8-
"version": "19.0.2.0.0",
8+
"version": "19.0.2.0.1",
99
"sequence": 1,
1010
"author": "OpenSPP.org",
1111
"website": "https://github.com/OpenSPP/OpenSPP2",
@@ -38,6 +38,8 @@
3838
"spp_base_common/static/src/xml/custom_list_create_template.xml",
3939
"spp_base_common/static/src/js/filterable_radio_field.js",
4040
"spp_base_common/static/src/xml/filterable_radio_field.xml",
41+
"spp_base_common/static/src/xml/pager_hide_single.xml",
42+
"spp_base_common/static/src/scss/pager_hide_single.scss",
4143
],
4244
"web._assets_primary_variables": [
4345
"spp_base_common/static/src/scss/colors.scss",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// See OP#920 + spp_base_common/static/src/xml/pager_hide_single.xml.
2+
// The control-panel right-side toolbar (refresh button, embedded
3+
// actions, view switcher) had no vertical alignment of its own — it
4+
// relied on the pager's h-100 nav to anchor the row's height.
5+
// Once the pager is hidden, those siblings collapse to top-aligned.
6+
// Set align-items: center explicitly so they stay vertically centred
7+
// whether the pager is visible or not.
8+
.o_control_panel_navigation {
9+
align-items: center;
10+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
Hide the form-view "1/1" pager when there's only one record to navigate.
4+
5+
The standard web.Pager renders the counter + chevrons even when
6+
`total === 1`, leaving a disabled "1/1 < >" widget that confuses
7+
users. We drop the entire <nav> with `t-if` and pair the change
8+
with an `align-items: center` rule on the parent
9+
`o_control_panel_navigation` (see pager_hide_single.scss) so the
10+
sibling refresh button stays vertically centred without the
11+
pager's old h-100 anchor. `1/1+` (updateTotal set) stays visible
12+
because the count may still grow.
13+
14+
See OP#920.
15+
-->
16+
<templates xml:space="preserve">
17+
<t
18+
t-name="spp_base_common.PagerHideSingle"
19+
t-inherit="web.Pager"
20+
t-inherit-mode="extension"
21+
>
22+
<xpath expr="//nav[hasclass('o_pager')]" position="attributes">
23+
<attribute name="t-if">props.total &gt; 1 or props.updateTotal</attribute>
24+
</xpath>
25+
</t>
26+
</templates>

spp_change_request_v2/README.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,20 @@ Before declaring a new CR type complete:
853853
Changelog
854854
=========
855855

856+
19.0.2.0.6
857+
~~~~~~~~~~
858+
859+
- fix(views): route post-submit CRs (pending / approved / applied /
860+
rejected) through the stage review form when opened from the list,
861+
matching the Edit Details → Upload Documents → Review & Submit
862+
breadcrumb workflow used for fresh CRs (#920 round-2). Demo-generated
863+
CRs in "Applied" state previously landed on the legacy main form view
864+
from the list — now they open in ``spp_change_request_review_form``
865+
like manually-created CRs. Adds the missing
866+
``_action_open_review_form`` / ``_action_open_documents_form`` helpers
867+
and wires ``action="action_open_stage_form" type="object"`` on the CR
868+
list so row-click goes through the stage router.
869+
856870
19.0.2.0.5
857871
~~~~~~~~~~
858872

spp_change_request_v2/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "OpenSPP Change Request V2",
3-
"version": "19.0.2.0.5",
3+
"version": "19.0.2.0.6",
44
"sequence": 50,
55
"category": "OpenSPP",
66
"summary": "Configuration-driven change request system with UX improvements, conflict detection and duplicate prevention",

spp_change_request_v2/models/change_request.py

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ def _on_submit(self):
10181018
action = "resubmitted" if old_state == "revision" else "submitted"
10191019
self._create_audit_event("submitted", old_state, "pending")
10201020
self._create_log(action)
1021+
self.stage = "review"
10211022

10221023
def _on_request_revision(self, notes):
10231024
super()._on_request_revision(notes)
@@ -1523,29 +1524,63 @@ def action_upload_document(self):
15231524
def action_open_stage_form(self):
15241525
"""Open the appropriate form view based on the current stage.
15251526
1526-
For draft/revision CRs: routes to the stage-specific form.
1527-
For other states: opens the main CR form (for validators/managers).
1527+
- **Draft / revision**: route by `stage` to the editable stage form
1528+
(details / documents / review).
1529+
- **Submitted+ (pending, approved, applied, rejected)**: always open
1530+
the review-stage form. That form already renders state-aware
1531+
headers (Approve/Reject for validators, Apply for managers,
1532+
Applied ribbon for completed, Start Over for rejected) and shows
1533+
the same Edit Details → Upload Documents → Review & Submit
1534+
breadcrumb. Without this, validators/managers (and demo-applied
1535+
CRs opened from the list) landed on the legacy main form view
1536+
which lacks the breadcrumb and the pager-hide treatment. See
1537+
OP#920 round-2.
15281538
"""
15291539
self.ensure_one()
15301540

1531-
if self.approval_state not in ("draft", "revision"):
1532-
return {
1533-
"type": "ir.actions.act_window",
1534-
"name": self.name,
1535-
"res_model": "spp.change.request",
1536-
"res_id": self.id,
1537-
"view_mode": "form",
1538-
"views": [[False, "form"]],
1539-
"target": "current",
1540-
}
1541+
if self.approval_state in ("draft", "revision"):
1542+
if self.stage == "documents":
1543+
return self._action_open_documents_form()
1544+
if self.stage == "review":
1545+
return self._action_open_review_form()
1546+
return self.action_open_detail()
1547+
1548+
# pending / approved / applied / rejected
1549+
return self._action_open_review_form()
15411550

1542-
if self.stage == "documents":
1543-
return self._action_open_documents_form()
1544-
if self.stage == "review":
1545-
return self._action_open_review_form()
1551+
def _action_open_review_form(self):
1552+
"""Open the CR in the Review & Submit stage form view."""
1553+
self.ensure_one()
1554+
view = self.env.ref(
1555+
"spp_change_request_v2.spp_change_request_review_form",
1556+
raise_if_not_found=False,
1557+
)
1558+
return {
1559+
"type": "ir.actions.act_window",
1560+
"name": self.name,
1561+
"res_model": "spp.change.request",
1562+
"res_id": self.id,
1563+
"view_mode": "form",
1564+
"views": [[view.id if view else False, "form"]],
1565+
"target": "current",
1566+
}
15461567

1547-
# Default: details stage
1548-
return self.action_open_detail()
1568+
def _action_open_documents_form(self):
1569+
"""Open the CR in the Upload Documents stage form view."""
1570+
self.ensure_one()
1571+
view = self.env.ref(
1572+
"spp_change_request_v2.spp_change_request_documents_form",
1573+
raise_if_not_found=False,
1574+
)
1575+
return {
1576+
"type": "ir.actions.act_window",
1577+
"name": self.name,
1578+
"res_model": "spp.change.request",
1579+
"res_id": self.id,
1580+
"view_mode": "form",
1581+
"views": [[view.id if view else False, "form"]],
1582+
"target": "current",
1583+
}
15491584

15501585
def action_goto_details(self):
15511586
"""Navigate to the details stage (replaces breadcrumb via client action)."""

spp_change_request_v2/readme/HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 19.0.2.0.6
2+
3+
- fix(views): route post-submit CRs (pending / approved / applied / rejected) through the stage review form when opened from the list, matching the Edit Details → Upload Documents → Review & Submit breadcrumb workflow used for fresh CRs (#920 round-2). Demo-generated CRs in "Applied" state previously landed on the legacy main form view from the list — now they open in `spp_change_request_review_form` like manually-created CRs. Adds the missing `_action_open_review_form` / `_action_open_documents_form` helpers and wires `action="action_open_stage_form" type="object"` on the CR list so row-click goes through the stage router.
4+
15
### 19.0.2.0.5
26

37
- fix(security): add a global `ir.rule` on `spp.change.request` that filters by `registrant_id.area_id` against the user's `center_area_ids` (OP#989 round-2). The earlier `_prepare_domain` override only caught `search_read` / `web_search_read` and missed the registrant Many2one picker (which uses `name_search``_search`), so users could still select out-of-area registrants. The conditional domain is a no-op for users with no center areas (global roles).

spp_change_request_v2/static/description/index.html

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,21 @@ <h2>Changelog</h2>
13391339
</div>
13401340
</div>
13411341
<div class="section" id="section-1">
1342+
<h1>19.0.2.0.6</h1>
1343+
<ul class="simple">
1344+
<li>fix(views): route post-submit CRs (pending / approved / applied /
1345+
rejected) through the stage review form when opened from the list,
1346+
matching the Edit Details → Upload Documents → Review &amp; Submit
1347+
breadcrumb workflow used for fresh CRs (#920 round-2). Demo-generated
1348+
CRs in “Applied” state previously landed on the legacy main form view
1349+
from the list — now they open in <tt class="docutils literal">spp_change_request_review_form</tt>
1350+
like manually-created CRs. Adds the missing
1351+
<tt class="docutils literal">_action_open_review_form</tt> / <tt class="docutils literal">_action_open_documents_form</tt> helpers
1352+
and wires <tt class="docutils literal"><span class="pre">action=&quot;action_open_stage_form&quot;</span> <span class="pre">type=&quot;object&quot;</span></tt> on the CR
1353+
list so row-click goes through the stage router.</li>
1354+
</ul>
1355+
</div>
1356+
<div class="section" id="section-2">
13421357
<h1>19.0.2.0.5</h1>
13431358
<ul class="simple">
13441359
<li>fix(security): add a global <tt class="docutils literal">ir.rule</tt> on <tt class="docutils literal">spp.change.request</tt> that
@@ -1351,27 +1366,27 @@ <h1>19.0.2.0.5</h1>
13511366
roles).</li>
13521367
</ul>
13531368
</div>
1354-
<div class="section" id="section-2">
1369+
<div class="section" id="section-3">
13551370
<h1>19.0.2.0.3</h1>
13561371
<ul class="simple">
13571372
<li>fix: add HTML escaping to all computed Html fields with
13581373
<tt class="docutils literal">sanitize=False</tt> to prevent stored XSS (#50)</li>
13591374
</ul>
13601375
</div>
1361-
<div class="section" id="section-3">
1376+
<div class="section" id="section-4">
13621377
<h1>19.0.2.0.2</h1>
13631378
<ul class="simple">
13641379
<li>fix: fix batch approval wizard line deletion (#130)</li>
13651380
</ul>
13661381
</div>
1367-
<div class="section" id="section-4">
1382+
<div class="section" id="section-5">
13681383
<h1>19.0.2.0.1</h1>
13691384
<ul class="simple">
13701385
<li>fix: skip field types before getattr and isolate detail prefetch
13711386
(#129)</li>
13721387
</ul>
13731388
</div>
1374-
<div class="section" id="section-5">
1389+
<div class="section" id="section-6">
13751390
<h1>19.0.2.0.0</h1>
13761391
<ul class="simple">
13771392
<li>Initial migration to OpenSPP2</li>

spp_change_request_v2/tests/test_stage_navigation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,16 @@ def test_action_open_stage_form_draft_review(self):
116116
cr.action_open_stage_form()
117117

118118
def test_action_open_stage_form_pending(self):
119-
"""Pending CR opens main form (not stage form)."""
119+
"""Pending CR opens the Review & Submit stage form so post-submit
120+
states share the breadcrumb-based UI with draft / revision."""
120121
cr = self._create_cr()
121122
cr.approval_state = "pending"
122123
result = cr.action_open_stage_form()
123124
self.assertEqual(result["type"], "ir.actions.act_window")
124125
self.assertEqual(result["res_model"], "spp.change.request")
125126
self.assertEqual(result["res_id"], cr.id)
126-
self.assertEqual(result["views"], [[False, "form"]])
127+
review_view = self.env.ref("spp_change_request_v2.spp_change_request_review_form")
128+
self.assertEqual(result["views"], [[review_view.id, "form"]])
127129

128130
def test_action_start_over_creates_new_cr(self):
129131
"""action_start_over() creates a new CR with same type and registrant."""

spp_change_request_v2/views/change_request_views.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
decoration-warning="display_state == 'revision'"
1414
create="0"
1515
sample="1"
16+
action="action_open_stage_form"
17+
type="object"
1618
>
1719
<field name="name" decoration-bf="1" />
1820
<field name="request_type_id" />

0 commit comments

Comments
 (0)