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
12 changes: 12 additions & 0 deletions spp_drims/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ Dependencies
Changelog
=========

19.0.4.0.4
~~~~~~~~~~

- fix(drims): name constants after codes the vocabulary actually ships,
and fix the three places that used the wrong ones. An urgent request
answered a 24-hour approval SLA instead of 8 hours, the priority badge
and list decorations never fired, and the High Priority search filter
always returned nothing — all because the code asked for priorities
the data does not contain. A test now walks every code constant
against its vocabulary, so one naming a code that does not exist fails
the build instead of silently matching nothing (#1165)

19.0.4.0.3
~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion spp_drims/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"and distribution tracking. Links to hazard incidents with multi-tier "
"approval workflows and warehouse operations.",
"category": "OpenSPP/Inventory",
"version": "19.0.4.0.3",
"version": "19.0.4.0.4",
"sequence": 1,
"author": "OpenSPP.org",
"website": "https://github.com/OpenSPP/OpenSPP2",
Expand Down
9 changes: 2 additions & 7 deletions spp_drims/data/config_defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<field name="value">4</field>
</record>

<record id="default_sla_hours_high" model="ir.config_parameter">
<field name="key">drims.sla.hours.high</field>
<record id="default_sla_hours_urgent" model="ir.config_parameter">
<field name="key">drims.sla.hours.urgent</field>
<field name="value">8</field>
</record>

Expand All @@ -22,11 +22,6 @@
<field name="value">24</field>
</record>

<record id="default_sla_hours_low" model="ir.config_parameter">
<field name="key">drims.sla.hours.low</field>
<field name="value">48</field>
</record>

<record id="default_sla_warning_threshold_pct" model="ir.config_parameter">
<field name="key">drims.sla.warning_threshold_pct</field>
<field name="value">75</field>
Expand Down
59 changes: 47 additions & 12 deletions spp_drims/models/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,64 @@
"""
DRIMS Constants

This module defines vocabulary namespace URIs and other constants used across
the DRIMS module. Using constants ensures consistency and makes URIs easier
to maintain.
Vocabulary namespace URIs and the code values within them, used across the DRIMS
module so that neither has to be written as a bare string.

**Every code constant is named after the code it holds.** Four constants used to
be named for a concept that had no matching code in the shipped vocabulary data
(``PRIORITY_LOW``/``MEDIUM``/``HIGH`` and ``DRIMS_TYPE_TRANSFER``), so anything
comparing against them silently never matched — a ``search`` for a non-existent
code returns an empty set rather than raising. Mirroring the code in the name
removes the guesswork (OP#1165).

``CODE_NAMESPACES`` at the bottom records which vocabulary each group of code
constants belongs to. ``spp_drims/tests/test_constants.py`` walks it and asserts
every constant resolves to a real ``spp.vocabulary.code``, so a typo or a renamed
code fails the build instead of quietly never matching. Add new groups there.
"""

# Vocabulary Namespace Base URI
VOCAB_BASE = "urn:openspp:vocab:drims"

# Vocabulary Namespace URIs
VOCAB_AGENCY_TYPES = f"{VOCAB_BASE}:agency-types"
VOCAB_ALERT_TYPES = f"{VOCAB_BASE}:alert-types"
VOCAB_DONOR_TYPES = f"{VOCAB_BASE}:donor-types"
VOCAB_COORDINATION_MODES = f"{VOCAB_BASE}:coordination-modes"
VOCAB_DISTRIBUTION_TYPES = f"{VOCAB_BASE}:distribution-types"
VOCAB_DONATION_STATES = f"{VOCAB_BASE}:donation-states"
VOCAB_DONOR_TYPES = f"{VOCAB_BASE}:donor-types"
VOCAB_DRIMS_TYPES = f"{VOCAB_BASE}:drims-types"
VOCAB_HAZARD_TYPES = f"{VOCAB_BASE}:hazard-types"
VOCAB_ITEM_CATEGORIES = f"{VOCAB_BASE}:item-categories"
VOCAB_ITEM_CONDITIONS = f"{VOCAB_BASE}:item-conditions"
VOCAB_ITEM_DISPOSITIONS = f"{VOCAB_BASE}:item-dispositions"
VOCAB_ORGANIZATION_ROLES = f"{VOCAB_BASE}:organization-roles"
VOCAB_PERSONNEL_ROLES = f"{VOCAB_BASE}:personnel-roles"
VOCAB_POD_STATUSES = f"{VOCAB_BASE}:pod-statuses"
VOCAB_PRIORITY_LEVELS = f"{VOCAB_BASE}:priority-levels"
VOCAB_REQUEST_STATES = f"{VOCAB_BASE}:request-states"
VOCAB_RESTRICTIONS = f"{VOCAB_BASE}:restrictions"
VOCAB_RETURN_CONDITIONS = f"{VOCAB_BASE}:return-conditions"
VOCAB_RETURN_REASONS = f"{VOCAB_BASE}:return-reasons"
VOCAB_TRANSPORT_MODES = f"{VOCAB_BASE}:transport-modes"
VOCAB_ITEM_CONDITIONS = f"{VOCAB_BASE}:item-conditions"
VOCAB_ITEM_DISPOSITIONS = f"{VOCAB_BASE}:item-dispositions"

# Common state codes
# Request state codes (spp.drims.request)
STATE_DRAFT = "draft"
STATE_SUBMITTED = "submitted"
STATE_APPROVED = "approved"
STATE_REJECTED = "rejected"
STATE_ALLOCATED = "allocated"
STATE_DISPATCHED = "dispatched"
STATE_DELIVERED = "delivered"
STATE_FULFILLED = "fulfilled"
STATE_CANCELLED = "cancelled"

# Donation-line disposition codes that should NOT be stocked. Moves for these
# get cancelled at stocking, and the items then need a follow-up disposal
# (return / dispose / quarantine) tracked on the line — see OP#1058.
NON_ACCEPT_DISPOSITIONS = ("return", "dispose", "quarantine")

# Donation state codes
# Donation state codes (spp.drims.donation)
DONATION_STATE_DRAFT = "draft"
DONATION_STATE_ANNOUNCED = "announced"
DONATION_STATE_RECEIVED = "received"
Expand All @@ -48,17 +71,29 @@
# DRIMS type codes (for stock.picking classification)
DRIMS_TYPE_DONATION_RECEIPT = "donation_receipt"
DRIMS_TYPE_REQUEST_DISPATCH = "request_dispatch"
DRIMS_TYPE_TRANSFER = "transfer"
DRIMS_TYPE_INTERNAL_TRANSFER = "internal_transfer"
DRIMS_TYPE_RETURN = "return"

# Alert type codes
ALERT_LOW_STOCK = "low_stock"
ALERT_EXPIRY = "expiry"
ALERT_SLA_BREACH = "sla_breach"
ALERT_SLA_WARNING = "sla_warning"
ALERT_CRITICAL_SHORTAGE = "critical_shortage"
ALERT_QUALITY_ISSUE = "quality_issue"

# Priority level codes
PRIORITY_LOW = "low"
PRIORITY_MEDIUM = "medium"
PRIORITY_HIGH = "high"
PRIORITY_ROUTINE = "routine"
PRIORITY_URGENT = "urgent"
PRIORITY_CRITICAL = "critical"

#: Which vocabulary each group of code constants draws from, keyed by the name
#: prefix. Walked by ``test_constants.py`` to prove every constant resolves.
#: Keep this in step when adding a group, or the new group goes unchecked.
CODE_NAMESPACES = {
"STATE_": VOCAB_REQUEST_STATES,
"DONATION_STATE_": VOCAB_DONATION_STATES,
"DRIMS_TYPE_": VOCAB_DRIMS_TYPES,
"ALERT_": VOCAB_ALERT_TYPES,
"PRIORITY_": VOCAB_PRIORITY_LEVELS,
}
2 changes: 1 addition & 1 deletion spp_drims/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def _compute_sla_status(self):

SLA thresholds are configurable via Settings > DRIMS Configuration
(requires spp_studio_drims module) or System Parameters:
- drims.sla.hours.critical/high/routine/low
- drims.sla.hours.critical/urgent/routine
- drims.sla.warning_threshold_pct
"""
now = fields.Datetime.now()
Expand Down
9 changes: 7 additions & 2 deletions spp_drims/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ def get_approval_sla_hours(self, priority_code):
"""Get approval SLA hours for a given priority code.

Args:
priority_code: One of 'critical', 'high', 'routine', 'low'
priority_code: a code from the DRIMS priority-levels vocabulary —
'critical', 'urgent' or 'routine'

Returns:
int: Hours allowed to approve requests of this priority
"""
# nosemgrep: odoo-sudo-without-context — standard Odoo pattern for system parameter access
ICP = self.env["ir.config_parameter"].sudo()
defaults = {"critical": 4, "high": 8, "routine": 24, "low": 48}
# Keyed by the codes the priority-levels vocabulary actually ships.
# This used to name 'high' and 'low', which no priority has, so an
# urgent request fell through to the routine default of 24 hours
# instead of 8 and nothing said so (OP#1165).
defaults = {"critical": 4, "urgent": 8, "routine": 24}
param_key = f"drims.sla.hours.{priority_code}"
return int(ICP.get_param(param_key, defaults.get(priority_code, 24)))

Expand Down
4 changes: 4 additions & 0 deletions spp_drims/readme/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 19.0.4.0.4

- fix(drims): name constants after codes the vocabulary actually ships, and fix the three places that used the wrong ones. An urgent request answered a 24-hour approval SLA instead of 8 hours, the priority badge and list decorations never fired, and the High Priority search filter always returned nothing — all because the code asked for priorities the data does not contain. A test now walks every code constant against its vocabulary, so one naming a code that does not exist fails the build instead of silently matching nothing (#1165)

### 19.0.4.0.3

- fix(drims): show only the states a dispatch can reach on its status bar. A request dispatch is confirmed the moment it is created, so Draft never applies to it; the shared status bar keeps Draft for every other outgoing transfer. Waiting is hidden as a future step but still shows when a dispatch is actually in it (#1086)
Expand Down
29 changes: 21 additions & 8 deletions spp_drims/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,19 @@ <h2><a class="toc-backref" href="#toc-entry-1">Changelog</a></h2>
</div>
</div>
<div class="section" id="section-1">
<h1>19.0.4.0.4</h1>
<ul class="simple">
<li>fix(drims): name constants after codes the vocabulary actually ships,
and fix the three places that used the wrong ones. An urgent request
answered a 24-hour approval SLA instead of 8 hours, the priority badge
and list decorations never fired, and the High Priority search filter
always returned nothing — all because the code asked for priorities
the data does not contain. A test now walks every code constant
against its vocabulary, so one naming a code that does not exist fails
the build instead of silently matching nothing (#1165)</li>
</ul>
</div>
<div class="section" id="section-2">
<h1>19.0.4.0.3</h1>
<ul class="simple">
<li>fix(drims): show only the states a dispatch can reach on its status
Expand All @@ -574,7 +587,7 @@ <h1>19.0.4.0.3</h1>
shows when a dispatch is actually in it (#1086)</li>
</ul>
</div>
<div class="section" id="section-2">
<div class="section" id="section-3">
<h1>19.0.4.0.2</h1>
<ul class="simple">
<li>feat(drims): confirm a delivery through a popup rather than the
Expand All @@ -584,7 +597,7 @@ <h1>19.0.4.0.2</h1>
reflects what was received rather than what was sent (#1088)</li>
</ul>
</div>
<div class="section" id="section-3">
<div class="section" id="section-4">
<h1>19.0.4.0.1</h1>
<ul class="simple">
<li>fix(drims): only let a dispatch ship what its request approved.
Expand All @@ -594,7 +607,7 @@ <h1>19.0.4.0.1</h1>
and delete affordances hidden to match (#1057)</li>
</ul>
</div>
<div class="section" id="section-4">
<div class="section" id="section-5">
<h1>19.0.4.0.0</h1>
<ul class="simple">
<li>feat(drims): Donations review — creation, receipt, inspection and
Expand All @@ -614,7 +627,7 @@ <h1>19.0.4.0.0</h1>
but no longer readable through the ORM or shown in any view (#1076)</li>
</ul>
</div>
<div class="section" id="section-5">
<div class="section" id="section-6">
<h1>19.0.3.1.0</h1>
<ul class="simple">
<li>feat(drims): Incident Management review — incidents are entered as a
Expand All @@ -631,7 +644,7 @@ <h1>19.0.3.1.0</h1>
refresh cron skips (#1100)</li>
</ul>
</div>
<div class="section" id="section-6">
<div class="section" id="section-7">
<h1>19.0.3.0.4</h1>
<ul class="simple">
<li>feat(drims): rework the dispatch page and correct the waybill.
Expand All @@ -651,7 +664,7 @@ <h1>19.0.3.0.4</h1>
barcode (#1151)</li>
</ul>
</div>
<div class="section" id="section-7">
<div class="section" id="section-8">
<h1>19.0.3.0.1</h1>
<ul class="simple">
<li>fix(drims): a dispatch validated short no longer leaves the request
Expand All @@ -663,7 +676,7 @@ <h1>19.0.3.0.1</h1>
API (#1087)</li>
</ul>
</div>
<div class="section" id="section-8">
<div class="section" id="section-9">
<h1>19.0.3.0.0</h1>
<ul class="simple">
<li>feat(drims): allocate stock per source warehouse. The Allocate Stock
Expand All @@ -683,7 +696,7 @@ <h1>19.0.3.0.0</h1>
destination-type selector (#1075)</li>
</ul>
</div>
<div class="section" id="section-9">
<div class="section" id="section-10">
<h1>19.0.2.0.0</h1>
<ul class="simple">
<li>Initial migration to OpenSPP2</li>
Expand Down
1 change: 1 addition & 0 deletions spp_drims/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
from . import common
from . import test_activity_feed
from . import test_constants
from . import test_alert
from . import test_allocation_preview_wizard
from . import test_approval
Expand Down
Loading
Loading