示例#1
0
 def test_allocation_request(self):
     """ Create an allocation request """
     # employee should be set to current user
     allocation_form = Form(self.env['hr.leave.allocation'].with_user(
         self.user_employee))
     allocation_form.name = 'New Allocation Request'
     allocation_form.holiday_status_id = self.holidays_type_2
     allocation = allocation_form.save()
示例#2
0
 def test_department_leave(self):
     """ Create a department leave """
     self.employee_hrmanager.write({'department_id': self.hr_dept.id})
     self.assertFalse(self.env['hr.leave'].search([
         ('employee_id', 'in', self.hr_dept.member_ids.ids)
     ]))
     leave_form = Form(self.env['hr.leave'].with_user(self.user_hrmanager),
                       view='hr_holidays.hr_leave_view_form_manager')
     leave_form.holiday_type = 'department'
     leave_form.department_id = self.hr_dept
     leave_form.holiday_status_id = self.holidays_type_1
     leave_form.request_date_from = date(2019, 5, 6)
     leave_form.request_date_to = date(2019, 5, 6)
     leave = leave_form.save()
     leave.action_approve()
     member_ids = self.hr_dept.member_ids.ids
     self.assertEqual(
         self.env['hr.leave'].search_count([('employee_id', 'in',
                                             member_ids)]), len(member_ids),
         "Leave should be created for members of department")
示例#3
0
 def test_timezone_company_validated(self):
     """ Create a leave request for a company in another timezone and validate it """
     self.env.user.tz = 'NZ'  # GMT+12
     company = self.env['res.company'].create({'name': "Hergé"})
     employee = self.env['hr.employee'].create({
         'name': "Remi",
         'company_id': company.id
     })
     leave_form = Form(self.env['hr.leave'],
                       view='hr_holidays.hr_leave_view_form_manager')
     leave_form.holiday_type = 'company'
     leave_form.mode_company_id = company
     leave_form.holiday_status_id = self.holidays_type_1
     leave_form.request_date_from = date(2019, 5, 6)
     leave_form.request_date_to = date(2019, 5, 6)
     leave = leave_form.save()
     leave.state = 'confirm'
     leave.action_validate()
     employee_leave = self.env['hr.leave'].search([('employee_id', '=',
                                                    employee.id)])
     self.assertEqual(
         employee_leave.request_date_from, date(2019, 5, 6),
         "Timezone should be kept between company and employee leave")