@ -30,7 +30,13 @@ class AttendanceSheetShift(models.AbstractModel):
ondelete = " cascade " ,
ondelete = " cascade " ,
)
)
stage = fields . Selection (
stage = fields . Selection (
[ ( " present " , " Present " ) , ( " absent " , " Absent " ) , ( " cancelled " , " Cancelled " ) ] ,
[
( " present " , " Present " ) ,
( " absent_0 " , " Absent / 0 Compensation " ) ,
( " absent_1 " , " Absent / 1 Compensation " ) ,
( " absent_2 " , " Absent / 2 Compensations " ) ,
( " cancelled " , " Cancelled " ) ,
] ,
string = " Shift Stage " ,
string = " Shift Stage " ,
)
)
@ -64,12 +70,11 @@ class AttendanceSheetShift(models.AbstractModel):
if self . working_mode == " regular " :
if self . working_mode == " regular " :
if self . stage == " present " :
if self . stage == " present " :
return " done "
return " done "
if self . stage == " absent " and self . compensation_nb :
if self . compensation_nb == " 0 " :
if self . stage == " absent_0 " :
return " excused_necessity "
return " excused_necessity "
if self . compensation_nb == " 1 " :
if self . stage == " absent_ 1" :
return " excused "
return " excused "
if self . compensation_nb == " 2 " :
if self . stage == " absent_ 2" :
return " absent "
return " absent "
if self . stage == " cancelled " :
if self . stage == " cancelled " :
return " cancel "
return " cancel "
@ -86,11 +91,6 @@ class AttendanceSheetShiftExpected(models.Model):
_description = " Expected Shift "
_description = " Expected Shift "
_inherit = [ " beesdoo.shift.sheet.shift " ]
_inherit = [ " beesdoo.shift.sheet.shift " ]
compensation_nb = fields . Selection (
[ ( " 0 " , " 0 " ) , ( " 1 " , " 1 " ) , ( " 2 " , " 2 " ) ] ,
string = " Compensations (if absent) " ,
)
replacement_worker_id = fields . Many2one (
replacement_worker_id = fields . Many2one (
" res.partner " ,
" res.partner " ,
string = " Replacement Worker " ,
string = " Replacement Worker " ,
@ -101,20 +101,6 @@ class AttendanceSheetShiftExpected(models.Model):
] ,
] ,
)
)
# The webclient has display issues with this method.
@api.onchange ( " stage " )
def on_change_stage ( self ) :
if self . working_mode == " irregular " :
if self . stage == " present " or " cancelled " :
self . compensation_nb = False
if self . stage == " absent " :
self . compensation_nb = " 1 "
if self . working_mode == " regular " :
if self . stage == " present " or " cancelled " :
self . compensation_nb = False
if self . stage == " absent " :
self . compensation_nb = " 2 "
class AttendanceSheetShiftAdded ( models . Model ) :
class AttendanceSheetShiftAdded ( models . Model ) :
""" The added shifts stage must be Present
""" The added shifts stage must be Present
@ -330,9 +316,9 @@ class AttendanceSheet(models.Model):
task_templates = set ( )
task_templates = set ( )
for task in tasks :
for task in tasks :
if task . working_mode == " irregular " :
if task . working_mode == " irregular " :
compensation_nb = " 1 "
stage = " absent_ 1"
else :
else :
compensation_nb = " 2 "
stage = " absent_ 2"
if task . worker_id :
if task . worker_id :
new_expected_shift = expected_shift . create (
new_expected_shift = expected_shift . create (
{
{
@ -341,8 +327,7 @@ class AttendanceSheet(models.Model):
" worker_id " : task . worker_id . id ,
" worker_id " : task . worker_id . id ,
" replacement_worker_id " : task . replaced_id . id ,
" replacement_worker_id " : task . replaced_id . id ,
" task_type_id " : task . task_type_id . id ,
" task_type_id " : task . task_type_id . id ,
" stage " : " absent " ,
" compensation_nb " : compensation_nb ,
" stage " : stage ,
" working_mode " : task . working_mode ,
" working_mode " : task . working_mode ,
}
}
)
)