diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py
index bf73e4de3b1..a8d140e5749 100644
--- a/addons/mrp/models/mrp_workorder.py
+++ b/addons/mrp/models/mrp_workorder.py
@@ -117,8 +117,10 @@ class MrpWorkorder(models.Model):
time_ids = fields.One2many(
'mrp.workcenter.productivity', 'workorder_id')
is_user_working = fields.Boolean(
- 'Is the Current User Working', compute='_compute_is_user_working',
+ 'Is the Current User Working', compute='_compute_working_users',
help="Technical field indicating whether the current user is working. ")
+ working_user_ids = fields.One2many('res.users', string='Working user on this work order.', compute='_compute_working_users')
+ last_working_user_id = fields.One2many('res.users', string='Last user that worked on this work order.', compute='_compute_working_users')
production_messages = fields.Html('Workorder Message', compute='_compute_production_messages')
next_work_order_id = fields.Many2one('mrp.workorder', "Next Work Order")
@@ -149,9 +151,14 @@ class MrpWorkorder(models.Model):
else:
self.duration_percent = 0
- def _compute_is_user_working(self):
- """ Checks whether the current user is working """
+ def _compute_working_users(self):
+ """ Checks whether the current user is working, all the users currently working and the last user that worked. """
for order in self:
+ order.working_user_ids = [(4, order.id) for order in order.time_ids.filtered(lambda time: not time.date_end).sorted('date_start').mapped('user_id')]
+ if order.working_user_ids:
+ order.last_working_user_id = order.working_user_ids[-1]
+ elif order.time_ids:
+ order.last_working_user_id = order.time_ids.sorted('date_end')[-1].user_id
if order.time_ids.filtered(lambda x: (x.user_id.id == self.env.user.id) and (not x.date_end) and (x.loss_type in ('productive', 'performance'))):
order.is_user_working = True
else:
diff --git a/addons/mrp/views/mrp_workorder_views.xml b/addons/mrp/views/mrp_workorder_views.xml
index a3522f85999..521e861341a 100644
--- a/addons/mrp/views/mrp_workorder_views.xml
+++ b/addons/mrp/views/mrp_workorder_views.xml
@@ -328,6 +328,10 @@
+
+
+
+
@@ -336,13 +340,22 @@
-
-
-
-
-
+
+
+ -
+
+
+
+
+
-
-
+
+
+
+
+
+
+