[IMP] mrp: computed blocking time based on working hours or wc
for machine blocks only, as people can do extra hours
This commit is contained in:
@@ -202,8 +202,14 @@ class MrpWorkcenterProductivity(models.Model):
|
||||
def _compute_duration(self):
|
||||
for blocktime in self:
|
||||
if blocktime.date_end:
|
||||
diff = fields.Datetime.from_string(blocktime.date_end) - fields.Datetime.from_string(blocktime.date_start)
|
||||
blocktime.duration = round(diff.total_seconds() / 60.0, 2)
|
||||
d1 = fields.Datetime.from_string(blocktime.date_start)
|
||||
d2 = fields.Datetime.from_string(blocktime.date_end)
|
||||
diff = d2 - d1
|
||||
if (blocktime.loss_type not in ('productive', 'performance')) and blocktime.workcenter_id.calendar_id:
|
||||
r = blocktime.workcenter_id.calendar_id.get_working_hours(d1, d2, resource_id=blocktime.workcenter_id.resource_id.id)
|
||||
blocktime.duration = round(r * 60, 2)
|
||||
else:
|
||||
blocktime.duration = round(diff.total_seconds() / 60.0, 2)
|
||||
else:
|
||||
blocktime.duration = 0.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user