[IMP]hr_employee_stats_sheet:conciderate only valided and active leaves
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hr_employee_stats_sheet",
|
"name": "hr_employee_stats_sheet",
|
||||||
"version": "16.0.3.1.3",
|
"version": "16.0.3.2.0",
|
||||||
"description": "Add global sheet for employee stats",
|
"description": "Add global sheet for employee stats",
|
||||||
"summary": "Add global sheet for employee stats",
|
"summary": "Add global sheet for employee stats",
|
||||||
"author": "Nicolas JEUDY",
|
"author": "Nicolas JEUDY",
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ class HrEmployeeStats(models.Model):
|
|||||||
("holiday_status_id", "!=", self._get_holiday_status_id()),
|
("holiday_status_id", "!=", self._get_holiday_status_id()),
|
||||||
("request_date_from", "<=", self.date),
|
("request_date_from", "<=", self.date),
|
||||||
("request_date_to", ">=", self.date),
|
("request_date_to", ">=", self.date),
|
||||||
|
("state", '=', 'validate'),
|
||||||
|
("active", '=', True),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
if leave_ids:
|
if leave_ids:
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ class TestHrEmployeeStatsRecovery(TransactionCase):
|
|||||||
self.employee.resource_calendar_id = self.base_calendar
|
self.employee.resource_calendar_id = self.base_calendar
|
||||||
self.env.company.recovery_type_id = self.recovery_type
|
self.env.company.recovery_type_id = self.recovery_type
|
||||||
self.env.company.coef = 25
|
self.env.company.coef = 25
|
||||||
|
analytic_plan = self.env['account.analytic.plan'].create({
|
||||||
|
'name': 'Test Plan',
|
||||||
|
})
|
||||||
|
self.analytic_account = self.env['account.analytic.account'].create({
|
||||||
|
'name': 'Test Analytic Account',
|
||||||
|
'plan_id': analytic_plan.id,
|
||||||
|
})
|
||||||
|
|
||||||
def _create_timesheet_sheet(self, start_date):
|
def _create_timesheet_sheet(self, start_date):
|
||||||
# Create a timesheet for the week (Monday to Sunday)
|
# Create a timesheet for the week (Monday to Sunday)
|
||||||
@@ -57,7 +64,7 @@ class TestHrEmployeeStatsRecovery(TransactionCase):
|
|||||||
'employee_id': self.employee.id,
|
'employee_id': self.employee.id,
|
||||||
'date': start_date + timedelta(days=i),
|
'date': start_date + timedelta(days=i),
|
||||||
'unit_amount': unit_amount,
|
'unit_amount': unit_amount,
|
||||||
'account_id': 1,
|
'account_id': self.analytic_account.id,
|
||||||
'name': 'Work Entry',
|
'name': 'Work Entry',
|
||||||
})
|
})
|
||||||
# Generate hr.employee.stats for each day of the period
|
# Generate hr.employee.stats for each day of the period
|
||||||
@@ -259,7 +266,6 @@ class TestHrEmployeeStatsRecovery(TransactionCase):
|
|||||||
for stat in stats:
|
for stat in stats:
|
||||||
stat._compute_dayofweek()
|
stat._compute_dayofweek()
|
||||||
stat._compute_hours()
|
stat._compute_hours()
|
||||||
print("stat :", stat.date, stat.total_hours, stat.total_planned_hours, stat.gap_hours)
|
|
||||||
timesheet_sheet.action_generate_recovery_allocation()
|
timesheet_sheet.action_generate_recovery_allocation()
|
||||||
self.assertEqual(timesheet_sheet.timesheet_sheet_gap_hours, 0, "timesheet_sheet_gap_hours should be 0",)
|
self.assertEqual(timesheet_sheet.timesheet_sheet_gap_hours, 0, "timesheet_sheet_gap_hours should be 0",)
|
||||||
self.assertEqual(timesheet_sheet.timesheet_sheet_recovery_hours, 0, "timesheet_sheet_recovery_hours should be 0",)
|
self.assertEqual(timesheet_sheet.timesheet_sheet_recovery_hours, 0, "timesheet_sheet_recovery_hours should be 0",)
|
||||||
@@ -320,7 +326,6 @@ class TestHrEmployeeStatsRecovery(TransactionCase):
|
|||||||
for stat in stats:
|
for stat in stats:
|
||||||
stat._compute_dayofweek()
|
stat._compute_dayofweek()
|
||||||
stat._compute_hours()
|
stat._compute_hours()
|
||||||
print("stat :", stat.date, stat.total_hours, stat.total_planned_hours, stat.gap_hours)
|
|
||||||
timesheet_sheet_1.action_generate_recovery_allocation()
|
timesheet_sheet_1.action_generate_recovery_allocation()
|
||||||
self.assertEqual(timesheet_sheet_1.timesheet_sheet_gap_hours, 5, "timesheet_sheet_gap_hours should be 0",)
|
self.assertEqual(timesheet_sheet_1.timesheet_sheet_gap_hours, 5, "timesheet_sheet_gap_hours should be 0",)
|
||||||
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",)
|
||||||
|
|||||||
Reference in New Issue
Block a user