[FIX] mrp: review and workorder wizard modification
The workorder wizard helping to track the time spend on the workorders has been automated. The name of the employee will automatically be the name of the admin of the session. The productivity will also be updated based on the duration The duration, start date and end date will update based on the two other ones. This changes will ease the addition of time trackings. closes odoo/odoo#107473 Related: odoo/enterprise#34786 Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
@@ -419,6 +419,21 @@ class MrpWorkcenterProductivity(models.Model):
|
||||
else:
|
||||
blocktime.duration = 0.0
|
||||
|
||||
@api.onchange('duration')
|
||||
def _duration_changed(self):
|
||||
self.date_end = self.date_start + timedelta(minutes=self.duration)
|
||||
self._loss_type_change()
|
||||
|
||||
@api.onchange('date_start')
|
||||
def _date_start_changed(self):
|
||||
self.date_end = self.date_start + timedelta(minutes=self.duration)
|
||||
self._loss_type_change()
|
||||
|
||||
@api.onchange('date_end')
|
||||
def _date_end_changed(self):
|
||||
self.date_start = self.date_end - timedelta(minutes=self.duration)
|
||||
self._loss_type_change()
|
||||
|
||||
@api.constrains('workorder_id')
|
||||
def _check_open_time_ids(self):
|
||||
for workorder in self.workorder_id:
|
||||
@@ -430,6 +445,13 @@ class MrpWorkcenterProductivity(models.Model):
|
||||
self.ensure_one()
|
||||
self.workcenter_id.order_ids.end_all()
|
||||
|
||||
def _loss_type_change(self):
|
||||
self.ensure_one()
|
||||
if self.workorder_id.duration > self.workorder_id.duration_expected:
|
||||
self.loss_id = self.env.ref("mrp.block_reason4").id
|
||||
else:
|
||||
self.loss_id = self.env.ref("mrp.block_reason7").id
|
||||
|
||||
def _close(self):
|
||||
underperformance_timers = self.env['mrp.workcenter.productivity']
|
||||
for timer in self:
|
||||
|
||||
@@ -887,4 +887,4 @@ class MrpWorkorder(models.Model):
|
||||
if wo.duration == 0.0:
|
||||
wo.duration = wo.duration_expected
|
||||
wo.duration_percent = 100
|
||||
wo.state = 'done'
|
||||
wo.state = 'done'
|
||||
|
||||
Reference in New Issue
Block a user