File: test_global_time_off.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (53 lines) | stat: -rw-r--r-- 2,259 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# # -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from .common import TestWorkEntryBase

from datetime import datetime

from odoo.tests import tagged

@tagged('-at_install', 'post_install')
class TestGlobalTimeOff(TestWorkEntryBase):

    def test_gto_other_calendar(self):
        # Tests that a global time off in another calendar does not affect work entry generation
        #  for other calendars
        other_calendar = self.env['resource.calendar'].create({
            'name': 'other calendar',
        })
        start = datetime(2018, 1, 1, 0, 0, 0)
        end = datetime(2018, 1, 1, 23, 59, 59)
        leave = self.env['resource.calendar.leaves'].create({
            'date_from': start,
            'date_to': end,
            'calendar_id': other_calendar.id,
            'work_entry_type_id': self.work_entry_type_leave.id,
        })
        contract = self.richard_emp.contract_ids
        contract.state = 'open'
        contract.date_generated_from = start
        contract.date_generated_to = start
        work_entries = contract.generate_work_entries(start.date(), end.date())
        self.assertEqual(work_entries.work_entry_type_id.id, contract._get_default_work_entry_type_id())
        work_entries.unlink()
        contract.date_generated_from = start
        contract.date_generated_to = start
        leave.calendar_id = contract.resource_calendar_id
        work_entries = contract.generate_work_entries(start.date(), end.date())
        self.assertEqual(work_entries.work_entry_type_id, leave.work_entry_type_id)

    def test_gto_no_calendar(self):
        start = datetime(2018, 1, 1, 0, 0, 0)
        end = datetime(2018, 1, 1, 23, 59, 59)
        leave = self.env['resource.calendar.leaves'].create({
            'date_from': start,
            'date_to': end,
            'work_entry_type_id': self.work_entry_type_leave.id,
        })
        contract = self.richard_emp.contract_ids
        contract.state = 'open'
        contract.date_generated_from = start
        contract.date_generated_to = start
        work_entries = contract.generate_work_entries(start.date(), end.date())
        self.assertEqual(work_entries.work_entry_type_id, leave.work_entry_type_id)