File: test_calendar_with_recurrence.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 (72 lines) | stat: -rw-r--r-- 3,192 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from odoo.tests import HttpCase, tagged
from datetime import datetime, time
from dateutil.relativedelta import relativedelta


@tagged('post_install', '-at_install')
class TestCalendarWithRecurrence(HttpCase):

    def test_dblclick_event_from_calendar(self):
        """Make sure double clicking on an event and its recurrences lead to the correct record"""
        self.env['maintenance.team'].create({
            'name': 'the boys',
        })
        equipment = self.env['maintenance.equipment'].create({
            'name': 'room'
        })
        requests = self.env['maintenance.request'].create([{
            'name': 'send the mails',
            'schedule_date': datetime.now() + relativedelta(weeks=-2),
        }, {
            'name': 'wash the car',
            'schedule_date': datetime.now() + relativedelta(weeks=+3),
        }, {
            'name': 'clean the room',
            'schedule_date': datetime.now(),
            'equipment_id': equipment.id,  # necessary for the tour to work with mrp_maintenance installed
            'maintenance_type': 'preventive',
            'recurring_maintenance': True,
            'repeat_until': datetime.now() + relativedelta(days=+8),
            'repeat_interval': 1,
            'repeat_unit': 'day',
            'duration': 1,
        }])
        request = requests[2]

        url = '/odoo/action-maintenance.hr_equipment_request_action_cal'
        self.start_tour(url, 'test_dblclick_event_from_calendar', login='admin')

        self.assertEqual(request.name, 'make your bed', "The event modification should update the request")
        self.assertEqual(request.duration, 2, "The event modification should update the request")

    def test_drag_and_drop_calendar_event(self):
        """
        Make sure dragging and dropping an event changes the correct record
        Occurences should be locked, drag and drop should have no effect
        """
        self.env['maintenance.team'].create({
            'name': 'the boys',
        })
        requests = self.env['maintenance.request'].create([{
            'name': 'send the mails',
            'schedule_date': datetime.now() + relativedelta(months=-2),
        }, {
            'name': 'wash the car',
            'schedule_date': datetime.now() + relativedelta(months=+1),
        }, {
            'name': 'clean the room',
            'schedule_date': datetime.combine(datetime.now().replace(day=6), time.min.replace(hour=10)),  # 6th of the month at 10 AM
            'maintenance_type': 'preventive',
            'recurring_maintenance': True,
            'repeat_interval': 1,
            'repeat_until': datetime.now() + relativedelta(weeks=+2),
            'repeat_unit': 'week',
            'duration': 1,
        }])
        request = requests[2]

        url = '/odoo/action-maintenance.hr_equipment_request_action_cal'
        self.start_tour(url, 'test_drag_and_drop_event_in_calendar', login='admin')

        target_datetime = datetime.combine(datetime.now().replace(day=15), time.min.replace(hour=10))  # 15h of the month at 10 AM
        self.assertEqual(request.schedule_date, target_datetime, "The event modification should update the request")