Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
366ca58
fix(drims): incident dashboard Units/Products (incident-related, net …
emjay0921 Jul 24, 2026
8af05f7
fix(drims): hide Impact tab on incidents pending #1155 (#1159)
emjay0921 Jul 24, 2026
6b0048b
fix(drims): limit actions on closed incidents — requests, donations, …
emjay0921 Jul 24, 2026
b8fd85c
feat(drims): add 'Flag As Alert' button to set incidents to alert sta…
emjay0921 Jul 24, 2026
c71274c
fix(drims): stop dashboard KPI boxes navigating to incident; only nam…
emjay0921 Jul 24, 2026
085c119
fix(drims): refresh incident stock value KPI when warehouse incident_…
emjay0921 Jul 24, 2026
3dd2dbe
feat(drims): define incident warehouses bidirectionally + filter dona…
emjay0921 Jul 29, 2026
aa0a1df
Merge remote-tracking branch 'origin/19.0' into feat/1100-drims-incid…
emjay0921 Aug 7, 2026
9e3ddd9
fix(hazard): raise incidents in Alert and lead with Flag As Alert
emjay0921 Aug 10, 2026
8830547
fix(hazard): stop a closed incident linking out to its hazard category
emjay0921 Aug 11, 2026
959a67b
Merge remote-tracking branch 'origin/19.0' into feat/1100-drims-incid…
emjay0921 Aug 11, 2026
987e841
test(drims): allocate through allocation rows in the incident KPI tests
emjay0921 Aug 11, 2026
a866e12
feat(hazard): enter incidents as drafts and classify them explicitly
emjay0921 Aug 12, 2026
1d7db31
Merge remote-tracking branch 'origin/19.0' into feat/1100-drims-incid…
emjay0921 Aug 14, 2026
c433ad8
test(spp_drims): give the OP#1164 donation fixtures a line
emjay0921 Aug 19, 2026
f559229
fix(spp_drims): address the incident management review — upgrade path…
emjay0921 Aug 19, 2026
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
16 changes: 16 additions & 0 deletions spp_drims/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,22 @@ Dependencies
Changelog
=========

19.0.3.1.0
~~~~~~~~~~

- feat(drims): Incident Management review — incidents are entered as a
**Draft** and then flagged Alert or set Active, a closed incident
refuses DRIMS operations and no longer accepts lifecycle changes,
dashboard KPI cards no longer open the record when a box is clicked,
warehouses can be linked to an incident and drive the warehouse
choices on donations and requests, and the Impact tab is hidden where
it does not apply (#1094, #1123, #1157, #1158, #1159, #1160, #1164)
- fix(drims): incident stock KPIs now count incident-related stock net
of allocations, and distributed value is net of confirmed returns.
Both are stored computes whose meaning changed, so upgrading
recomputes them for every incident — including closed ones, which the
refresh cron skips (#1100)

19.0.3.0.0
~~~~~~~~~~

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.3.0.0",
"version": "19.0.3.1.0",
"sequence": 1,
"author": "OpenSPP.org",
"website": "https://github.com/OpenSPP/OpenSPP2",
Expand Down
11 changes: 11 additions & 0 deletions spp_drims/data/config_defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,15 @@
<field name="key">drims.performance.kpi_cache_ttl_minutes</field>
<field name="value">30</field>
</record>

<!-- =================================================================== -->
<!-- WAREHOUSE SETTINGS -->
<!-- =================================================================== -->
<!-- OP#1164: when True, the warehouse pickers on donations/requests are
restricted to the incident's linked warehouses. Set False to allow
selecting from any DRIMS warehouse. -->
<record id="default_warehouse_filter_by_incident" model="ir.config_parameter">
<field name="key">drims.warehouse.filter_by_incident</field>
<field name="value">True</field>
</record>
</odoo>
61 changes: 61 additions & 0 deletions spp_drims/migrations/19.0.3.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
"""Recompute the incident KPIs whose meaning changed in this version (OP#1100).

Three stored computes were redefined rather than added:

* ``drims_total_stock_units`` and ``drims_stock_item_count`` went from
"everything physically in the warehouse" to "incident-related stock net of
what has been allocated out".
* ``drims_distributed_value`` is now net of confirmed returns.

Odoo only computes a stored field for existing rows when its column is newly
created, so an upgraded database keeps the old numbers until something happens
to touch a dependency. For a quiet incident that may be never — and closed
incidents are excluded from ``_cron_refresh_drims_kpis``, so nothing would ever
correct them.

The cached ``spp.data.value`` rows behind the value KPIs hold pre-change
numbers for the same reason, and the compute prefers a live cache entry over
recomputing, so they are dropped first.
"""

import logging

from odoo import SUPERUSER_ID, api

_logger = logging.getLogger(__name__)

STALE_CACHE_VARIABLES = ("drims_distributed_value", "drims_stock_value")

RECOMPUTED_FIELDS = (
"drims_total_stock_units",
"drims_stock_item_count",
"drims_distributed_value",
)


def migrate(cr, version):
if not version:
return

env = api.Environment(cr, SUPERUSER_ID, {})

data_value = env.get("spp.data.value")
if data_value is not None:
for variable in STALE_CACHE_VARIABLES:
data_value.invalidate(variable_name=variable)
_logger.info("Dropped cached values for %s", ", ".join(STALE_CACHE_VARIABLES))

# Every incident, not just the open ones: the cron that would otherwise
# heal these skips closed incidents, which is exactly where a stale number
# would sit unnoticed.
incidents = env["spp.hazard.incident"].search([])
if not incidents:
return

for field_name in RECOMPUTED_FIELDS:
field = incidents._fields.get(field_name)
if field is not None:
env.add_to_compute(field, incidents)
env.flush_all()
_logger.info("Recomputed %s for %d incident(s)", ", ".join(RECOMPUTED_FIELDS), len(incidents))
21 changes: 21 additions & 0 deletions spp_drims/models/donation.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ class DrimsDonation(models.Model):
string="Receiving Warehouse",
required=True,
tracking=True,
domain="[('id', 'in', allowed_warehouse_ids)]",
)
# OP#1164: warehouses selectable for this donation — the incident's linked
# warehouses when incident-filtering is enabled, otherwise all DRIMS
# warehouses. Used to domain the Receiving Warehouse field.
allowed_warehouse_ids = fields.Many2many(
"stock.warehouse",
compute="_compute_allowed_warehouse_ids",
string="Allowed Warehouses",
)

# Dates
Expand Down Expand Up @@ -245,6 +254,15 @@ def _compute_has_acceptable_items(self):
for line in rec.line_ids
)

@api.depends("incident_id", "incident_id.drims_warehouse_ids")
def _compute_allowed_warehouse_ids(self):
"""OP#1164: selectable warehouses = the incident's warehouses when
incident-filtering is on (and the incident has any), else all DRIMS
warehouses. The fallback avoids locking out donation creation when an
incident has no warehouses linked yet."""
for rec in self:
rec.allowed_warehouse_ids = rec.incident_id._drims_allowed_warehouses()

@api.depends("picking_ids")
def _compute_picking_count(self):
for rec in self:
Expand All @@ -253,6 +271,9 @@ def _compute_picking_count(self):
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
# OP#1158: no new donations may be accepted for a closed incident.
if vals.get("incident_id"):
self.env["spp.hazard.incident"].browse(vals["incident_id"])._drims_ensure_open(_("accept a donation"))
if vals.get("reference", _("New")) == _("New"):
vals["reference"] = self.env["ir.sequence"].next_by_code("spp.drims.donation") or _("New")
records = super().create(vals_list)
Expand Down
Loading
Loading