File: test_task_tracking.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 (39 lines) | stat: -rw-r--r-- 1,492 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
# -*- coding: utf-8 -*-

from odoo.tests import tagged

from odoo.addons.project.tests.test_project_base import TestProjectCommon


@tagged('-at_install', 'post_install')
class TestTaskTracking(TestProjectCommon):

    def flush_tracking(self):
        """ Force the creation of tracking values. """
        self.env.flush_all()
        self.cr.precommit.run()

    def test_many2many_tracking(self):
        # Basic test
        # Assign new user
        self.cr.precommit.clear()
        self.task_1.user_ids += self.user_projectmanager
        self.flush_tracking()
        self.assertEqual(len(self.task_1.message_ids), 1,
            "Assigning a new user should log a message.")
        # No change
        self.task_1.user_ids += self.user_projectmanager
        self.flush_tracking()
        self.assertEqual(len(self.task_1.message_ids), 1,
            "Assigning an already assigned user should not log a message.")
        # Removing assigness
        self.task_1.user_ids = False
        self.flush_tracking()
        self.assertEqual(len(self.task_1.message_ids), 2,
            "Removing both assignees should only log one message.")

    def test_many2many_tracking_context(self):
        # Test that the many2many tracking does not throw an error when using
        #  default values for fields that exists both on tasks and on messages
        # Using an invalid value for this test
        self.task_1.with_context(default_parent_id=-1).user_ids += self.user_projectmanager