Files
odoo_source/addons/project/tests/test_task_tracking.py
T
William Braeckman a3a32c66fd [IMP] project: improve on x2many tracking
While investigating an issue with the x2many tracking, we found a
better way that to track those field while also fixing the issue.

Fixes an issue with `default_*` context keys that are used in the
project app upon writing on tasks.

TaskId-2725014

closes odoo/odoo#82189

X-original-commit: a281a18fc84a09177f7b5e8aab98b8dc34dcc3b8
Signed-off-by: Xavier <xbo@odoo.com>
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-01-04 08:47:07 +00:00

40 lines
1.5 KiB
Python

# -*- 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['base'].flush()
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