diff --git a/fusion_repairs/__manifest__.py b/fusion_repairs/__manifest__.py index ca76d998..0b01f46b 100644 --- a/fusion_repairs/__manifest__.py +++ b/fusion_repairs/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Fusion Repairs', - 'version': '19.0.1.6.0', + 'version': '19.0.1.7.0', 'category': 'Inventory/Repairs', 'summary': 'Guided medical equipment repair intake, dispatch, maintenance, and self-service portal', 'description': """ diff --git a/fusion_repairs/models/technician_task.py b/fusion_repairs/models/technician_task.py index 76162f83..36792c33 100644 --- a/fusion_repairs/models/technician_task.py +++ b/fusion_repairs/models/technician_task.py @@ -42,6 +42,49 @@ class FusionTechnicianTaskRepairs(models.Model): copy=False, ) + # ------------------------------------------------------------------ + # T3 - Labour timer. The tech taps Start when they begin work and + # Stop when done; the accumulated minutes feeds the visit-report + # actual hours field. Multiple start/stop cycles are accumulated. + # ------------------------------------------------------------------ + x_fc_timer_running_since = fields.Datetime( + string='Timer Running Since', + copy=False, + ) + x_fc_timer_accumulated_minutes = fields.Float( + string='Accumulated Minutes', + default=0.0, + copy=False, + help='Total labour minutes captured by the tech timer. ' + 'Divide by 60 for the hours that prefill the visit report.', + ) + + def action_timer_start(self): + for t in self: + if t.x_fc_timer_running_since: + continue # already running + t.x_fc_timer_running_since = fields.Datetime.now() + t.message_post(body=Markup(_('Labour timer started.'))) + + def action_timer_stop(self): + for t in self: + if not t.x_fc_timer_running_since: + continue + from datetime import datetime + elapsed_minutes = ( + datetime.now() - t.x_fc_timer_running_since + ).total_seconds() / 60.0 + t.x_fc_timer_accumulated_minutes = ( + t.x_fc_timer_accumulated_minutes or 0.0 + ) + elapsed_minutes + t.x_fc_timer_running_since = False + t.message_post(body=Markup(_( + 'Labour timer stopped. Added %(mins).1f min, total %(tot).1f min.' + )) % { + 'mins': elapsed_minutes, + 'tot': t.x_fc_timer_accumulated_minutes or 0.0, + }) + def write(self, vals): """When a maintenance task transitions to 'completed', roll the linked contract to its next cycle. Failure to roll never blocks diff --git a/fusion_repairs/views/technician_task_views.xml b/fusion_repairs/views/technician_task_views.xml index f1a1e234..2d78de05 100644 --- a/fusion_repairs/views/technician_task_views.xml +++ b/fusion_repairs/views/technician_task_views.xml @@ -22,10 +22,26 @@ class="btn-secondary" icon="fa-wrench" invisible="not x_fc_repair_order_id"/> +