From f990f290197f72d643ef87d6669d73161178e2d5 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Wed, 29 Apr 2026 23:48:34 -0400 Subject: [PATCH] feat(plating-jobs): state-aware sort + default Open filter on Plating Jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Plating Jobs list was sorted priority-desc, deadline-asc, id-desc — which mixed Done (closed) jobs in with Confirmed (open) jobs and made the list look chaotic to managers. Done jobs from weeks ago surfaced above active work. Two changes: 1. New stored compute fp.job.state_priority (Integer, indexed) ranks states by managerial relevance: in_progress=0, confirmed=1, draft=2, on_hold=3, done=4, cancelled=5. _order now leads with state_priority asc, then priority desc, then date_deadline asc, then id desc. Active work bubbles to the top automatically. 2. Plating Jobs action defaults to a new 'Open' filter (state not in done, cancelled). Managers see only active work by default; they untick the filter to see history. Added On Hold + Cancelled filters too for full state coverage. Verified on entech: top 10 jobs are now all in_progress, sorted by deadline ascending. Existing 26-row list goes from chaotic to focused. Co-Authored-By: Claude Opus 4.7 (1M context) --- fusion_plating/fusion_plating/__manifest__.py | 2 +- .../fusion_plating/models/fp_job.py | 29 ++++++++++++++++++- .../fusion_plating/views/fp_job_views.xml | 11 +++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/fusion_plating/fusion_plating/__manifest__.py b/fusion_plating/fusion_plating/__manifest__.py index 93e9cd03..22b28990 100644 --- a/fusion_plating/fusion_plating/__manifest__.py +++ b/fusion_plating/fusion_plating/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Fusion Plating', - 'version': '19.0.18.7.3', + 'version': '19.0.18.7.4', 'category': 'Manufacturing/Plating', 'summary': 'Core plating / metal finishing ERP: facilities, processes, tanks, baths, jobs, operators.', 'description': """ diff --git a/fusion_plating/fusion_plating/models/fp_job.py b/fusion_plating/fusion_plating/models/fp_job.py index 321dadd5..3ca8b7ba 100644 --- a/fusion_plating/fusion_plating/models/fp_job.py +++ b/fusion_plating/fusion_plating/models/fp_job.py @@ -52,7 +52,11 @@ class FpJob(models.Model): return dt.astimezone(tz).strftime(fmt) _description = 'Plating Job' _inherit = ['mail.thread', 'mail.activity.mixin'] - _order = 'priority desc, date_deadline asc, id desc' + # Sub 12d — state-aware sort. Active work bubbles to the top + # (in_progress → confirmed/draft → on_hold → done → cancelled), + # then high-priority first within each state, then nearest deadline. + # state_priority is a small stored compute below. + _order = 'state_priority asc, priority desc, date_deadline asc, id desc' _rec_name = 'name' name = fields.Char( @@ -76,6 +80,29 @@ class FpJob(models.Model): tracking=True, index=True, ) + # Sub 12d — drives the default sort so active jobs surface above + # closed jobs. Lower number = sorted earlier. Stored + indexed so + # SQL ORDER BY hits an index and doesn't recompute per row. + state_priority = fields.Integer( + string='State Priority', + compute='_compute_state_priority', + store=True, + index=True, + ) + + _STATE_SORT_RANK = { + 'in_progress': 0, + 'confirmed': 1, + 'draft': 2, + 'on_hold': 3, + 'done': 4, + 'cancelled': 5, + } + + @api.depends('state') + def _compute_state_priority(self): + for rec in self: + rec.state_priority = self._STATE_SORT_RANK.get(rec.state, 9) priority = fields.Selection( [ ('low', 'Low'), diff --git a/fusion_plating/fusion_plating/views/fp_job_views.xml b/fusion_plating/fusion_plating/views/fp_job_views.xml index 9697bf95..2680fa44 100644 --- a/fusion_plating/fusion_plating/views/fp_job_views.xml +++ b/fusion_plating/fusion_plating/views/fp_job_views.xml @@ -100,10 +100,18 @@ + + + + + @@ -120,5 +128,8 @@ fp.job list,form + + {'search_default_open_jobs': 1}