diff --git a/hr_employee_stats_sheet/__manifest__.py b/hr_employee_stats_sheet/__manifest__.py index cfd2cd1..6eb55a7 100755 --- a/hr_employee_stats_sheet/__manifest__.py +++ b/hr_employee_stats_sheet/__manifest__.py @@ -1,6 +1,6 @@ { "name": "hr_employee_stats_sheet", - "version": "16.0.3.1.3", + "version": "16.0.3.2.0", "description": "Add global sheet for employee stats", "summary": "Add global sheet for employee stats", "author": "Nicolas JEUDY", diff --git a/hr_employee_stats_sheet/models/hr_employee_stats.py b/hr_employee_stats_sheet/models/hr_employee_stats.py index bd313c0..32bef82 100644 --- a/hr_employee_stats_sheet/models/hr_employee_stats.py +++ b/hr_employee_stats_sheet/models/hr_employee_stats.py @@ -143,6 +143,8 @@ class HrEmployeeStats(models.Model): ("holiday_status_id", "!=", self._get_holiday_status_id()), ("request_date_from", "<=", self.date), ("request_date_to", ">=", self.date), + ("state", '=', 'validate'), + ("active", '=', True), ], ) if leave_ids: diff --git a/hr_employee_stats_sheet/tests/test_employee_stats.py b/hr_employee_stats_sheet/tests/test_employee_stats.py index fd99a93..8d1c218 100644 --- a/hr_employee_stats_sheet/tests/test_employee_stats.py +++ b/hr_employee_stats_sheet/tests/test_employee_stats.py @@ -41,6 +41,13 @@ class TestHrEmployeeStatsRecovery(TransactionCase): self.employee.resource_calendar_id = self.base_calendar self.env.company.recovery_type_id = self.recovery_type 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): # Create a timesheet for the week (Monday to Sunday) @@ -57,7 +64,7 @@ class TestHrEmployeeStatsRecovery(TransactionCase): 'employee_id': self.employee.id, 'date': start_date + timedelta(days=i), 'unit_amount': unit_amount, - 'account_id': 1, + 'account_id': self.analytic_account.id, 'name': 'Work Entry', }) # Generate hr.employee.stats for each day of the period @@ -259,7 +266,6 @@ class TestHrEmployeeStatsRecovery(TransactionCase): for stat in stats: stat._compute_dayofweek() stat._compute_hours() - print("stat :", stat.date, stat.total_hours, stat.total_planned_hours, stat.gap_hours) 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_recovery_hours, 0, "timesheet_sheet_recovery_hours should be 0",) @@ -320,7 +326,6 @@ class TestHrEmployeeStatsRecovery(TransactionCase): for stat in stats: stat._compute_dayofweek() stat._compute_hours() - print("stat :", stat.date, stat.total_hours, stat.total_planned_hours, stat.gap_hours) 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_recovery_hours, 6.25, "timesheet_sheet_recovery_hours should be 6,25",)