@@ -128,27 +128,8 @@ class TestHrEmployeeStatsRecovery(TransactionCase):
timesheet_sheet . action_generate_recovery_allocation ( )
timesheet_sheet . action_generate_recovery_allocation ( )
recovery_allocation = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet . id ) ] )
recovery_allocation = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet . id ) ] )
self . assertEqual ( len ( recovery_allocation ) , 1 , " There should be one recovery " )
self . assertEqual ( len ( recovery_allocation ) , 1 , " There should be one recovery " )
self . assertAlmost Equal ( recovery_allocation . number_of_hours_displ ay , 6.25 , msg = " The recovery allocation should display 6.25 hours " )
self . assertEqual ( recovery_allocation . number_of_d ays , 0.8928571428571429 , " The recovery allocation should be for 6.25h/7h = 0.8928571428571429 day " )
def test_recovery_allocation_hours_with_employee_calendar_different_from_planning ( self ) :
# the employee's resource calendar hours per day differs from the planning calendar one:
# the allocation must still display the recovery hours of the timesheet sheet
self . env [ ' hr.employee.calendar ' ] . create ( {
' employee_id ' : self . employee . id ,
' date_start ' : Date . to_date ( " 2025-01-01 " ) ,
' date_end ' : None ,
' calendar_id ' : self . base_calendar . id ,
} )
self . employee . resource_calendar_id . hours_per_day = 7.3
start_date = date . today ( ) - timedelta ( days = date . today ( ) . weekday ( ) + 7 ) # lundi de la semaine dernière
timesheet_sheet = self . _create_timesheet_sheet ( start_date )
list ( self . _create_stats ( start_date , 5 , 8 ) )
self . assertEqual ( timesheet_sheet . timesheet_sheet_recovery_hours , 6.25 , " timesheet_sheet_recovery_hours should be 6,25 " , )
timesheet_sheet . action_generate_recovery_allocation ( )
recovery_allocation = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet . id ) ] )
self . assertEqual ( len ( recovery_allocation ) , 1 , " There should be one recovery " )
self . assertAlmostEqual ( recovery_allocation . number_of_hours_display , 6.25 , msg = " The recovery allocation should display 6.25 hours " )
def test_negative_recovery_hours ( self ) :
def test_negative_recovery_hours ( self ) :
self . env [ ' hr.employee.calendar ' ] . create ( {
self . env [ ' hr.employee.calendar ' ] . create ( {
' employee_id ' : self . employee . id ,
' employee_id ' : self . employee . id ,
@@ -172,7 +153,7 @@ class TestHrEmployeeStatsRecovery(TransactionCase):
timesheet_sheet . action_generate_recovery_allocation ( )
timesheet_sheet . action_generate_recovery_allocation ( )
recovery_allocation = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet . id ) ] )
recovery_allocation = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet . id ) ] )
self . assertEqual ( len ( recovery_allocation ) , 1 , " There should be one recovery " )
self . assertEqual ( len ( recovery_allocation ) , 1 , " There should be one recovery " )
self . assertAlmost Equal ( recovery_allocation . number_of_hours_displ ay , - 5 , msg = " The recovery allocation should display -5 hours " )
self . assertEqual ( recovery_allocation . number_of_d ays , - 0.7142857142857143 , " The recovery allocation should be for -5/7 hours = − 0,714285714 " )
def test_sheet_totals_update_after_timesheet_change ( self ) :
def test_sheet_totals_update_after_timesheet_change ( self ) :
""" Regression test: the sheet totals must reflect the addition and
""" Regression test: the sheet totals must reflect the addition and
@@ -390,9 +371,7 @@ class TestHrEmployeeStatsRecovery(TransactionCase):
self . assertEqual ( timesheet_sheet_1 . timesheet_sheet_recovery_hours , 6.25 , " timesheet_sheet_recovery_hours should be 6,25 " , )
self . assertEqual ( timesheet_sheet_1 . timesheet_sheet_recovery_hours , 6.25 , " timesheet_sheet_recovery_hours should be 6,25 " , )
allocation_1 = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet_1 . id ) ] )
allocation_1 = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet_1 . id ) ] )
self . assertEqual ( len ( allocation_1 ) , 1 , " There should be one recovery " )
self . assertEqual ( len ( allocation_1 ) , 1 , " There should be one recovery " )
# days are computed with the employee's current calendar (9h/day), as Odoo does to display hours
self . assertEqual ( allocation_1 . number_of_days , 0.8928571428571429 , " The recovery allocation should be for 0.8928571428571429 day " )
self . assertAlmostEqual ( allocation_1 . number_of_days , 6.25 / 9 , msg = " The recovery allocation should be for 6.25/9 day " )
self . assertAlmostEqual ( allocation_1 . number_of_hours_display , 6.25 , msg = " The recovery allocation should display 6.25 hours " )
#create stats during period of part time calendar for the employee
#create stats during period of part time calendar for the employee
# generation 4 stats of 10h each, the employee is supposed to work 9h per day during 4 days
# generation 4 stats of 10h each, the employee is supposed to work 9h per day during 4 days
@@ -411,9 +390,8 @@ class TestHrEmployeeStatsRecovery(TransactionCase):
allocation_2 = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet_2 . id ) ] )
allocation_2 = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet_2 . id ) ] )
self . assertEqual ( len ( allocation_2 ) , 1 , " There should be one recovery " )
self . assertEqual ( len ( allocation_2 ) , 1 , " There should be one recovery " )
self . assertEqual ( allocation_2 . number_of_days , 0.5555555555555556 , " The recovery allocation should be for 0,555555556 (5/9) day " )
self . assertEqual ( allocation_2 . number_of_days , 0.5555555555555556 , " The recovery allocation should be for 0,555555556 (5/9) day " )
self . assertAlmostEqual ( allocation_2 . number_of_hours_display , 5 , msg = " The recovery allocation should display 5 hours " )
#check that allocation_1 hasn't changed
#check that allocation_1 hasn't changed
self . assertAlmost Equal ( allocation_1 . number_of_hours_displ ay , 6.25 , msg = " The recovery allocation should still display 6.25 hours " )
self . assertEqual ( allocation_1 . number_of_d ays , 0.8928571428571429 , " The recovery allocation should be for 0,892857143 day " )
def test_public_holiday ( self ) :
def test_public_holiday ( self ) :
self . env [ ' hr.employee.calendar ' ] . create ( {
self . env [ ' hr.employee.calendar ' ] . create ( {
@@ -453,7 +431,7 @@ class TestHrEmployeeStatsRecovery(TransactionCase):
timesheet_sheet . action_generate_recovery_allocation ( )
timesheet_sheet . action_generate_recovery_allocation ( )
recovery_allocation = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet . id ) ] )
recovery_allocation = self . env [ " hr.leave.allocation " ] . search ( [ ( " timesheet_sheet_id " , " = " , timesheet_sheet . id ) ] )
self . assertEqual ( len ( recovery_allocation ) , 1 , " Il doit y avoir une allocation de récupération générée " )
self . assertEqual ( len ( recovery_allocation ) , 1 , " Il doit y avoir une allocation de récupération générée " )
self . assertAlmost Equal ( recovery_allocation . number_of_hours_displ ay , 8.7 5 , msg = " The recovery allocation should display 8.75 hour s " )
self . assertEqual ( recovery_allocation . number_of_d ays , 1.2 5, " The recovery allocation should be 1,25 day s " )
@tagged ( " post_install " , " -at_install " )
@tagged ( " post_install " , " -at_install " )