training hours compute

This commit is contained in:
Esraa-Exp 2025-04-13 14:48:49 +02:00
parent b07cc412f5
commit a84228f2f3
1 changed files with 9 additions and 4 deletions

View File

@ -287,7 +287,9 @@ class HrOfficialMission(models.Model):
if item.hour_to > item.hour_from:
item.hour_duration = (item.hour_to - item.hour_from)
else:
raise exceptions.Warning(_('Hour to must be greater than hour from.'))
item.hour_duration = (24 -item.hour_from ) + item.hour_to
# raise exceptions.Warning(_('Hour to must be greater than hour from.'))
if item.mission_type.maximum_hours > 0.0:
if item.hour_duration > item.mission_type.maximum_hours:
item.hour_duration = 0.0
@ -340,7 +342,8 @@ class HrOfficialMission(models.Model):
line.hour_from = item.hour_from
if (line.hour_to - line.hour_from) < 0:
raise exceptions.Warning(_('Number of hours to must be greater than hours from'))
hours = (24 - line.hour_from) + line.hour_to
# raise exceptions.Warning(_('Number of hours to must be greater than hours from'))
else:
line.hours = (line.hour_to - line.hour_from)
line.total_hours = line.hours * line.days
@ -1183,7 +1186,8 @@ class HrOfficialMissionEmployee(models.Model):
if item.official_mission_id.hour_to and item.official_mission_id.hour_from:
if item.hour_from and item.hour_to:
if (item.hour_to - item.hour_from) < 0:
raise exceptions.Warning(_('Number of hours to must be greater than hours from'))
item.hours = (24 -item.hour_from ) + item.hour_to
# raise exceptions.Warning(_('Number of hours to must be greater than hours from'))
else:
item.hours = (item.hour_to - item.hour_from)
item.total_hours = item.hours * item.days
@ -1191,7 +1195,8 @@ class HrOfficialMissionEmployee(models.Model):
item.hour_from = item.official_mission_id.hour_from
item.hour_to = item.official_mission_id.hour_to
if (item.hour_to - item.hour_from) < 0:
raise exceptions.Warning(_('Number of hours to must be greater than hours from'))
item.hours = (24 -item.hour_from ) + item.hour_to
# raise exceptions.Warning(_('Number of hours to must be greater than hours from'))
else:
item.hours = (item.hour_to - item.hour_from)
item.total_hours = item.hours * item.days