Ejemplo n.º 1
0
    def setUpClass(cls):
        super(TestContractCalendars, cls).setUpClass()
        cls.calendar_richard = cls.env['resource.calendar'].create(
            {'name': 'Calendar of Richard'})
        cls.employee.resource_calendar_id = cls.calendar_richard

        cls.calendar_35h = cls.env['resource.calendar'].create(
            {'name': '35h calendar'})
        cls.calendar_35h._onchange_hours_per_day()  # update hours/day

        cls.contract_cdd = cls.env['hr.contract'].create({
            'date_end':
            Date.to_date('2015-11-15'),
            'date_start':
            Date.to_date('2015-01-01'),
            'name':
            'First CDD Contract for Richard',
            'resource_calendar_id':
            cls.calendar_35h.id,
            'wage':
            5000.0,
            'employee_id':
            cls.employee.id,
            'state':
            'close',
        })
Ejemplo n.º 2
0
    def test_contract_transfer_leaves(self):
        def create_calendar_leave(start, end, resource=None):
            return self.env['resource.calendar.leaves'].create({
                'name':
                'leave name',
                'date_from':
                start,
                'date_to':
                end,
                'resource_id':
                resource.id if resource else None,
                'calendar_id':
                self.employee.resource_calendar_id.id,
                'time_type':
                'leave',
            })

        start = Datetime.to_datetime('2015-11-17 07:00:00')
        end = Datetime.to_datetime('2015-11-20 18:00:00')
        leave1 = create_calendar_leave(start,
                                       end,
                                       resource=self.employee.resource_id)

        start = Datetime.to_datetime('2015-11-25 07:00:00')
        end = Datetime.to_datetime('2015-11-28 18:00:00')
        leave2 = create_calendar_leave(start,
                                       end,
                                       resource=self.employee.resource_id)

        # global leave
        start = Datetime.to_datetime('2015-11-25 07:00:00')
        end = Datetime.to_datetime('2015-11-28 18:00:00')
        leave3 = create_calendar_leave(start, end)

        self.calendar_richard.transfer_leaves_to(
            self.calendar_35h,
            resources=self.employee.resource_id,
            from_date=Date.to_date('2015-11-21'))

        self.assertEqual(leave1.calendar_id, self.calendar_richard,
                         "It should stay in Richard's calendar")
        self.assertEqual(leave3.calendar_id, self.calendar_richard,
                         "Global leave should stay in original calendar")
        self.assertEqual(leave2.calendar_id, self.calendar_35h,
                         "It should be transfered to the other calendar")

        # Transfer global leaves
        self.calendar_richard.transfer_leaves_to(
            self.calendar_35h,
            resources=None,
            from_date=Date.to_date('2015-11-21'))

        self.assertEqual(leave3.calendar_id, self.calendar_35h,
                         "Global leave should be transfered")
Ejemplo n.º 3
0
 def test_action_confirm(self):
     """ It should create a contract for each contract template used in
     order_line """
     self.order_line1.onchange_product()
     self.sale.action_confirm()
     contracts = self.sale.order_line.mapped('contract_id')
     self.assertEqual(len(contracts), 2)
     self.assertEqual(
         self.order_line1.contract_id.contract_template_id,
         self.contract_template1,
     )
     contract_line = self.order_line1.contract_id.contract_line_ids
     self.assertEqual(contract_line.date_start, Date.to_date('2018-01-01'))
     self.assertEqual(contract_line.date_end, Date.to_date('2018-12-31'))
     self.assertEqual(contract_line.recurring_next_date,
                      Date.to_date('2018-01-31'))
    def test_02_account_move_date_range_fy_id_search(self):
        january_2017 = Date.to_date("2017-01-01")
        january_2018 = Date.to_date("2018-01-01")
        january_2019 = Date.to_date("2019-01-01")

        move_2017 = self.create_account_move(january_2017)
        move_2018 = self.create_account_move(january_2018)
        move_2019 = self.create_account_move(january_2019)

        moves = self.AccountMoveObj.search([
            ("date_range_fy_id", "ilike", "2017"),
        ])

        self.assertTrue(
            all([
                move_2017 in moves,
                move_2018 not in moves,
                move_2019 not in moves,
            ]),
            msg="There should be only moves in 2017",
        )

        moves = self.AccountMoveObj.search([
            ("date_range_fy_id", "=", self.date_range_2017.id),
        ])

        self.assertTrue(
            all([
                move_2017 in moves,
                move_2018 not in moves,
                move_2019 not in moves,
            ]))

        moves = self.AccountMoveObj.search([
            (
                "date_range_fy_id",
                "in",
                (self.date_range_2017.id, self.date_range_2018.id),
            ),
        ])

        self.assertTrue(
            all([
                move_2017 in moves,
                move_2018 in moves,
                move_2019 not in moves,
            ]))
Ejemplo n.º 5
0
    def test_01_account_move_date_range_fy_id_compute(self):
        january_1st = Date.to_date('2017-01-01')
        move = self.create_account_move(january_1st)

        self.assertEquals(move.date_range_fy_id,
                          self.date_range_2017,
                          msg="Move period should be 2017")
        self.assertTrue(all([
            line.date_range_fy_id == self.date_range_2017
            for line in move.line_ids
        ]),
                        msg="All lines period should be 2017")

        january_2019 = Date.to_date('2019-01-01')
        move = self.create_account_move(january_2019)
        self.assertFalse(bool(move.date_range_fy_id),
                         msg="Move shouldn't have any date range")
Ejemplo n.º 6
0
    def test_02_account_move_date_range_fy_id_search(self):
        january_2017 = Date.to_date('2017-01-01')
        january_2018 = Date.to_date('2018-01-01')
        january_2019 = Date.to_date('2019-01-01')

        move_2017 = self.create_account_move(january_2017)
        move_2018 = self.create_account_move(january_2018)
        move_2019 = self.create_account_move(january_2019)

        moves = self.AccountMoveObj.search([
            ('date_range_fy_id', 'ilike', '2017'),
        ])

        self.assertTrue(all([
            move_2017 in moves,
            move_2018 not in moves,
            move_2019 not in moves,
        ]),
                        msg="There should be only moves in 2017")

        moves = self.AccountMoveObj.search([
            ('date_range_fy_id', '=', self.date_range_2017.id),
        ])

        self.assertTrue(
            all([
                move_2017 in moves,
                move_2018 not in moves,
                move_2019 not in moves,
            ]))

        moves = self.AccountMoveObj.search([
            ('date_range_fy_id', 'in', (self.date_range_2017.id,
                                        self.date_range_2018.id)),
        ])

        self.assertTrue(
            all([
                move_2017 in moves,
                move_2018 in moves,
                move_2019 not in moves,
            ]))
 def test_forecast_period_on_contract_line_update_10(self):
     self.acct_line.write({
         'date_start': "2019-01-14",
         'recurring_next_date': "2019-01-14",
         'date_end': "2020-01-14",
         'recurring_rule_type': "monthlylastday",
         'last_date_invoiced': False,
         'recurring_invoicing_type': 'pre-paid',
     })
     self.assertTrue(self.acct_line.forecast_period_ids)
     self.assertEqual(len(self.acct_line.forecast_period_ids), 13)
     self.assertEqual(
         (
             self.acct_line.forecast_period_ids[0].date_start,
             self.acct_line.forecast_period_ids[0].date_end,
             self.acct_line.forecast_period_ids[0].date_invoice,
         ),
         (
             Date.to_date("2019-01-14"),
             Date.to_date("2019-01-31"),
             Date.to_date("2019-01-14"),
         ),
     )
     self.assertEqual(
         (
             self.acct_line.forecast_period_ids[1].date_start,
             self.acct_line.forecast_period_ids[1].date_end,
             self.acct_line.forecast_period_ids[1].date_invoice,
         ),
         (
             Date.to_date("2019-02-01"),
             Date.to_date("2019-02-28"),
             Date.to_date("2019-02-01"),
         ),
     )
     self.assertEqual(
         (
             self.acct_line.forecast_period_ids[-1].date_start,
             self.acct_line.forecast_period_ids[-1].date_end,
             self.acct_line.forecast_period_ids[-1].date_invoice,
         ),
         (
             Date.to_date("2020-01-01"),
             Date.to_date("2020-01-14"),
             Date.to_date("2020-01-01"),
         ),
     )
Ejemplo n.º 8
0
 def test_action_confirm_without_contract_creation(self):
     """ It should create a contract for each contract template used in
     order_line """
     self.sale.company_id.create_contract_at_sale_order_confirmation = False
     self.order_line1.onchange_product()
     self.sale.action_confirm()
     self.assertEqual(len(self.sale.order_line.mapped('contract_id')), 0)
     self.assertTrue(self.sale.need_contract_creation)
     self.sale.action_create_contract()
     self.assertEqual(len(self.sale.order_line.mapped('contract_id')), 2)
     self.assertFalse(self.sale.need_contract_creation)
     self.assertEqual(
         self.order_line1.contract_id.contract_template_id,
         self.contract_template1,
     )
     contract_line = self.order_line1.contract_id.contract_line_ids
     self.assertEqual(contract_line.date_start, Date.to_date('2018-01-01'))
     self.assertEqual(contract_line.date_end, Date.to_date('2018-12-31'))
     self.assertEqual(contract_line.recurring_next_date,
                      Date.to_date('2018-01-31'))
Ejemplo n.º 9
0
 def test_onchange_product(self):
     """ It should get recurrence invoicing info to the sale line from
     its product """
     self.order_line1.onchange_product()
     self.assertEqual(
         self.order_line1.recurring_rule_type,
         self.product1.recurring_rule_type,
     )
     self.assertEqual(
         self.order_line1.recurring_invoicing_type,
         self.product1.recurring_invoicing_type,
     )
     self.assertEqual(self.order_line1.date_end, Date.to_date('2018-12-31'))
Ejemplo n.º 10
0
    def setUpClass(cls):
        super(TestWorkEntryBase, cls).setUpClass()

        cls.env.user.tz = 'Europe/Brussels'
        cls.env.ref('resource.resource_calendar_std').tz = 'Europe/Brussels'

        cls.dep_rd = cls.env['hr.department'].create({
            'name': 'Research & Development - Test',
        })

        # I create a new employee "Richard"
        cls.richard_emp = cls.env['hr.employee'].create({
            'name': 'Richard',
            'gender': 'male',
            'birthday': '1984-05-01',
            'country_id': cls.env.ref('base.be').id,
            'department_id': cls.dep_rd.id,
        })

        # I create a contract for "Richard"
        cls.env['hr.contract'].create({
            'date_end': Date.today() + relativedelta(years=2),
            'date_start': Date.to_date('2018-01-01'),
            'name': 'Contract for Richard',
            'wage': 5000.0,
            'employee_id': cls.richard_emp.id,
        })

        cls.work_entry_type = cls.env['hr.work.entry.type'].create({
            'name': 'Extra attendance',
            'is_leave': False,
            'code': 'WORKTEST200',
        })

        cls.work_entry_type_unpaid = cls.env['hr.work.entry.type'].create({
            'name': 'Unpaid Leave',
            'is_leave': True,
            'code': 'LEAVETEST300',
        })

        cls.work_entry_type_leave = cls.env['hr.work.entry.type'].create({
            'name': 'Leave',
            'is_leave': True,
            'code': 'LEAVETEST100'
        })
Ejemplo n.º 11
0
 def test_contract_upsell(self):
     """Should stop contract line at sale order line start date"""
     self.order_line1.contract_id = self.contract
     self.order_line1.contract_line_id = self.contract_line
     self.contract_line.date_end = Date.today() + relativedelta(months=4)
     self.contract_line.is_auto_renew = True
     self.order_line1.date_start = "2018-06-01"
     self.order_line1.onchange_product()
     self.sale.action_confirm()
     self.assertEqual(self.contract_line.date_end,
                      Date.to_date("2018-05-31"))
     self.assertFalse(self.contract_line.is_auto_renew)
     new_contract_line = self.env['contract.line'].search([
         ('sale_order_line_id', '=', self.order_line1.id)
     ])
     self.assertEqual(self.contract_line.successor_contract_line_id,
                      new_contract_line)
     self.assertEqual(new_contract_line.predecessor_contract_line_id,
                      self.contract_line)
Ejemplo n.º 12
0
    def test_duplicate_benefit_to_attendance(self):
        start = self.to_datetime_tz('2015-11-01 09:00:00')
        end = self.to_datetime_tz('2015-11-03 18:00:00')

        # Benefit (not leave) should be split in three attendance
        benef = self.env['hr.benefit'].create({
            'name':
            '1',
            'employee_id':
            self.richard_emp.id,
            'benefit_type_id':
            self.benefit_type.id,
            'contract_id':
            self.richard_emp.contract_id.id,
            'date_start':
            start,
            'date_stop':
            end,
        })
        benef._duplicate_to_calendar()
        attendance_nb = self.env['resource.calendar.attendance'].search_count([
            ('date_from', '>=', start.date()), ('date_to', '<=', end.date())
        ])
        self.assertEqual(attendance_nb, 3,
                         "It should create one calendar attendance per day")
        self.assertTrue(self.env['resource.calendar.attendance'].search([
            ('date_from', '=', Date.to_date('2015-11-01')),
            ('date_to', '=', Date.to_date('2015-11-01')),
            ('hour_from', '=', 9.0), ('hour_to', '>=', 23.9)
        ]))
        self.assertTrue(self.env['resource.calendar.attendance'].search([
            ('date_from', '=', Date.to_date('2015-11-02')),
            ('date_to', '=', Date.to_date('2015-11-02')),
            ('hour_from', '=', 0.0), ('hour_to', '>=', 23.9)
        ]))
        self.assertTrue(self.env['resource.calendar.attendance'].search([
            ('date_from', '=', Date.to_date('2015-11-03')),
            ('date_to', '=', Date.to_date('2015-11-03')),
            ('hour_from', '=', 0.0), ('hour_to', '=', 18.0)
        ]))
Ejemplo n.º 13
0
    def test_duplicate_benefit_to_attendance(self):
        start = self.to_datetime_tz('2015-11-01 09:00:00')
        end = self.to_datetime_tz('2015-11-03 18:00:00')

        # Benefit (not leave) should be split in three attendance
        benef = self.env['hr.benefit'].create({
            'name': '1',
            'employee_id': self.richard_emp.id,
            'benefit_type_id': self.benefit_type.id,
            'contract_id': self.richard_emp.contract_id.id,
            'date_start': start,
            'date_stop': end,
        })
        benef._duplicate_to_calendar()
        attendance_nb = self.env['resource.calendar.attendance'].search_count([
            ('date_from', '>=', start.date()),
            ('date_to', '<=', end.date())
        ])
        self.assertEqual(attendance_nb, 3, "It should create one calendar attendance per day")
        self.assertTrue(self.env['resource.calendar.attendance'].search([
            ('date_from', '=', Date.to_date('2015-11-01')),
            ('date_to', '=', Date.to_date('2015-11-01')),
            ('hour_from', '=', 9.0),
            ('hour_to', '>=', 23.9)
        ]))
        self.assertTrue(self.env['resource.calendar.attendance'].search([
            ('date_from', '=', Date.to_date('2015-11-02')),
            ('date_to', '=', Date.to_date('2015-11-02')),
            ('hour_from', '=', 0.0),
            ('hour_to', '>=', 23.9)
        ]))
        self.assertTrue(self.env['resource.calendar.attendance'].search([
            ('date_from', '=', Date.to_date('2015-11-03')),
            ('date_to', '=', Date.to_date('2015-11-03')),
            ('hour_from', '=', 0.0),
            ('hour_to', '=', 18.0)
        ]))
Ejemplo n.º 14
0
    def setUpClass(cls):
        super(TestResource, cls).setUpClass()
        cls.calendar_richard = cls.env['resource.calendar'].create(
            {'name': 'Calendar of Richard'})
        cls.employee.resource_calendar_id = cls.calendar_richard

        cls.calendar_35h = cls.env['resource.calendar'].create({
            'name':
            '35h calendar',
            'attendance_ids': [(0, 0, {
                'name': 'Monday Morning',
                'dayofweek': '0',
                'hour_from': 8,
                'hour_to': 12,
                'day_period': 'morning'
            }),
                               (0, 0, {
                                   'name': 'Monday Evening',
                                   'dayofweek': '0',
                                   'hour_from': 13,
                                   'hour_to': 16,
                                   'day_period': 'afternoon'
                               }),
                               (0, 0, {
                                   'name': 'Tuesday Morning',
                                   'dayofweek': '1',
                                   'hour_from': 8,
                                   'hour_to': 12,
                                   'day_period': 'morning'
                               }),
                               (0, 0, {
                                   'name': 'Tuesday Evening',
                                   'dayofweek': '1',
                                   'hour_from': 13,
                                   'hour_to': 16,
                                   'day_period': 'afternoon'
                               }),
                               (0, 0, {
                                   'name': 'Wednesday Morning',
                                   'dayofweek': '2',
                                   'hour_from': 8,
                                   'hour_to': 12,
                                   'day_period': 'morning'
                               }),
                               (0, 0, {
                                   'name': 'Wednesday Evening',
                                   'dayofweek': '2',
                                   'hour_from': 13,
                                   'hour_to': 16,
                                   'day_period': 'afternoon'
                               }),
                               (0, 0, {
                                   'name': 'Thursday Morning',
                                   'dayofweek': '3',
                                   'hour_from': 8,
                                   'hour_to': 12,
                                   'day_period': 'morning'
                               }),
                               (0, 0, {
                                   'name': 'Thursday Evening',
                                   'dayofweek': '3',
                                   'hour_from': 13,
                                   'hour_to': 16,
                                   'day_period': 'afternoon'
                               }),
                               (0, 0, {
                                   'name': 'Friday Morning',
                                   'dayofweek': '4',
                                   'hour_from': 8,
                                   'hour_to': 12,
                                   'day_period': 'morning'
                               }),
                               (0, 0, {
                                   'name': 'Friday Evening',
                                   'dayofweek': '4',
                                   'hour_from': 13,
                                   'hour_to': 16,
                                   'day_period': 'afternoon'
                               })],
        })
        cls.calendar_35h._onchange_hours_per_day()  # update hours/day

        cls.contract_cdd = cls.env['hr.contract'].create({
            'date_start':
            Date.to_date('2021-09-01'),
            'date_end':
            Date.to_date('2021-10-31'),
            'name':
            'First CDD Contract for Richard',
            'resource_calendar_id':
            cls.calendar_35h.id,
            'wage':
            5000.0,
            'employee_id':
            cls.employee.id,
            'state':
            'open',
        })
        cls.contract_cdi = cls.env['hr.contract'].create({
            'date_start':
            Date.to_date('2021-11-01'),
            'name':
            'CDI Contract for Richard',
            'resource_calendar_id':
            cls.calendar_richard.id,
            'wage':
            5000.0,
            'employee_id':
            cls.employee.id,
            'state':
            'draft',
            'kanban_state':
            'done',
        })
Ejemplo n.º 15
0
    def setUpClass(cls):
        super(TestPayslipBase, cls).setUpClass()
        cls.env.user.tz = 'Europe/Brussels'
        cls.env.ref('resource.resource_calendar_std').tz = 'Europe/Brussels'

        cls.dep_rd = cls.env['hr.department'].create({
            'name':
            'Research & Development - Test',
        })

        # I create a new employee "Richard"
        cls.richard_emp = cls.env['hr.employee'].create({
            'name':
            'Richard',
            'gender':
            'male',
            'birthday':
            '1984-05-01',
            'country_id':
            cls.env.ref('base.be').id,
            'department_id':
            cls.dep_rd.id,
        })

        # I create a new employee "Jules"
        cls.jules_emp = cls.env['hr.employee'].create({
            'name':
            'Jules',
            'gender':
            'male',
            'birthday':
            '1984-05-01',
            'country_id':
            cls.env.ref('base.be').id,
            'department_id':
            cls.dep_rd.id,
        })

        cls.structure_type = cls.env['hr.payroll.structure.type'].create({
            'name':
            'Test - Developer',
        })

        # I create a contract for "Richard"
        cls.env['hr.contract'].create({
            'date_end':
            Date.today() + relativedelta(years=2),
            'date_start':
            Date.to_date('2018-01-01'),
            'name':
            'Contract for Richard',
            'wage':
            5000.0,
            'employee_id':
            cls.richard_emp.id,
            'structure_type_id':
            cls.structure_type.id,
        })

        cls.work_entry_type = cls.env['hr.work.entry.type'].create({
            'name':
            'Extra attendance',
            'is_leave':
            False,
            'code':
            'WORKTEST200',
        })

        cls.work_entry_type_unpaid = cls.env['hr.work.entry.type'].create({
            'name':
            'Unpaid Leave',
            'is_leave':
            True,
            'code':
            'LEAVETEST300',
            'round_days':
            'HALF',
            'round_days_type':
            'DOWN',
        })

        cls.work_entry_type_leave = cls.env['hr.work.entry.type'].create({
            'name':
            'Leave',
            'is_leave':
            True,
            'code':
            'LEAVETEST100'
        })

        # I create a salary structure for "Software Developer"
        cls.developer_pay_structure = cls.env['hr.payroll.structure'].create({
            'name':
            'Salary Structure for Software Developer',
            'type_id':
            cls.structure_type.id,
            'unpaid_work_entry_type_ids':
            [(4, cls.work_entry_type_unpaid.id, False)]
        })

        cls.hra_rule = cls.env['hr.salary.rule'].create({
            'name':
            'House Rent Allowance',
            'sequence':
            5,
            'amount_select':
            'percentage',
            'amount_percentage':
            40.0,
            'amount_percentage_base':
            'contract.wage',
            'code':
            'HRA',
            'category_id':
            cls.env.ref('hr_payroll.ALW').id,
            'struct_id':
            cls.developer_pay_structure.id,
        })

        cls.conv_rule = cls.env['hr.salary.rule'].create({
            'name':
            'Conveyance Allowance',
            'sequence':
            10,
            'amount_select':
            'fix',
            'amount_fix':
            800.0,
            'code':
            'CA',
            'category_id':
            cls.env.ref('hr_payroll.ALW').id,
            'struct_id':
            cls.developer_pay_structure.id,
        })

        cls.mv_rule = cls.env['hr.salary.rule'].create({
            'name':
            'Meal Voucher',
            'sequence':
            16,
            'amount_select':
            'fix',
            'amount_fix':
            10,
            'quantity':
            'worked_days.WORK100 and worked_days.WORK100.number_of_days',
            'code':
            'MA',
            'category_id':
            cls.env.ref('hr_payroll.ALW').id,
            'struct_id':
            cls.developer_pay_structure.id,
        })

        cls.sum_of_alw = cls.env['hr.salary.rule'].create({
            'name':
            'Sum of Allowance category',
            'sequence':
            99,
            'amount_select':
            'code',
            'amount_python_compute':
            "result = payslip.sum_category('ALW', payslip.date_from, to_date=payslip.date_to)",
            'quantity':
            'worked_days.WORK100 and worked_days.WORK100.number_of_days',
            'code':
            'SUMALW',
            'category_id':
            cls.env.ref('hr_payroll.ALW').id,
            'struct_id':
            cls.developer_pay_structure.id,
        })

        cls.pf_rule = cls.env['hr.salary.rule'].create({
            'name':
            'Provident Fund',
            'sequence':
            120,
            'amount_select':
            'percentage',
            'amount_percentage':
            -12.5,
            'amount_percentage_base':
            'contract.wage',
            'code':
            'PF',
            'category_id':
            cls.env.ref('hr_payroll.DED').id,
            'struct_id':
            cls.developer_pay_structure.id,
        })

        cls.prof_tax_rule = cls.env['hr.salary.rule'].create({
            'name':
            'Professional Tax',
            'sequence':
            150,
            'amount_select':
            'fix',
            'amount_fix':
            -200.0,
            'code':
            'PT',
            'category_id':
            cls.env.ref('hr_payroll.DED').id,
            'struct_id':
            cls.developer_pay_structure.id,
        })
        cls.structure_type.default_struct_id = cls.developer_pay_structure
Ejemplo n.º 16
0
    def setUp(self):
        super(TestPayslipBase, self).setUp()

        # Some salary rules references
        self.hra_rule_id = self.ref(
            'hr_payroll.hr_salary_rule_houserentallowance1')
        self.conv_rule_id = self.ref(
            'hr_payroll.hr_salary_rule_convanceallowance1')
        self.prof_tax_rule_id = self.ref(
            'hr_payroll.hr_salary_rule_professionaltax1')
        self.pf_rule_id = self.ref('hr_payroll.hr_salary_rule_providentfund1')
        self.mv_rule_id = self.ref('hr_payroll.hr_salary_rule_meal_voucher')
        self.sum_of_alw_id = self.ref(
            'hr_payroll.hr_salary_rule_sum_alw_category')

        # I create a new employee "Richard"
        self.richard_emp = self.env['hr.employee'].create({
            'name':
            'Richard',
            'gender':
            'male',
            'birthday':
            '1984-05-01',
            'country_id':
            self.ref('base.be'),
            'department_id':
            self.ref('hr.dep_rd')
        })

        # I create a new employee "Jules"
        self.jules_emp = self.env['hr.employee'].create({
            'name':
            'Jules',
            'gender':
            'male',
            'birthday':
            '1984-05-01',
            'country_id':
            self.ref('base.be'),
            'department_id':
            self.ref('hr.dep_rd')
        })

        self.structure_type = self.env['hr.payroll.structure.type'].create({
            'name':
            'Test - Developer',
        })

        # I create a contract for "Richard"
        self.env['hr.contract'].create({
            'date_end':
            Date.to_date('2019-12-31'),
            'date_start':
            Date.to_date('2018-01-01'),
            'name':
            'Contract for Richard',
            'wage':
            5000.0,
            'employee_id':
            self.richard_emp.id,
            'structure_type_id':
            self.structure_type.id,
        })

        self.work_entry_type = self.env['hr.work.entry.type'].create({
            'name':
            'Extra attendance',
            'is_leave':
            False,
            'code':
            'WORKTEST200',
        })

        self.work_entry_type_unpaid = self.env['hr.work.entry.type'].create({
            'name':
            'Unpaid Leave',
            'is_leave':
            True,
            'code':
            'LEAVETEST300',
            'round_days':
            'HALF',
            'round_days_type':
            'DOWN',
        })
        self.leave_type_unpaid = self.env['hr.leave.type'].create({
            'name':
            'Unpaid Leaves',
            'time_type':
            'leave',
            'allocation_type':
            'no',
            'validity_start':
            False,
            'work_entry_type_id':
            self.work_entry_type_unpaid.id
        })

        self.work_entry_type_leave = self.env['hr.work.entry.type'].create({
            'name':
            'Leave',
            'is_leave':
            True,
            'code':
            'LEAVETEST100'
        })
        self.leave_type = self.env['hr.leave.type'].create({
            'name':
            'Legal Leaves',
            'time_type':
            'leave',
            'allocation_type':
            'no',
            'validity_start':
            False,
            'work_entry_type_id':
            self.work_entry_type_leave.id
        })

        # I create a salary structure for "Software Developer"
        self.developer_pay_structure = self.env['hr.payroll.structure'].create(
            {
                'name':
                'Salary Structure for Software Developer',
                'type_id':
                self.structure_type.id,
                'regular_pay':
                True,
                'rule_ids': [
                    (4, self.hra_rule_id),
                    (4, self.conv_rule_id),
                    (4, self.prof_tax_rule_id),
                    (4, self.pf_rule_id),
                    (4, self.mv_rule_id),
                    (4, self.sum_of_alw_id),
                ],
                'unpaid_work_entry_type_ids':
                [(4, self.work_entry_type_unpaid.id, False)]
            })