-
-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] project_task_add_very_high: Migration to 18.0
- Loading branch information
1 parent
4047123
commit 503f036
Showing
6 changed files
with
96 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
- Andrea Stirpe \<<a.stirpe@onestein.nl>\> | ||
- Yves Goldberg (Ygol InternetWork) <yves@ygol.com> | ||
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_project_task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestProjectTaskPriority(TransactionCase): | ||
def setUp(self): | ||
super().setUp() | ||
self.project_task_model = self.env["project.task"] | ||
|
||
def test_priority_selection(self): | ||
"""Test that the priority field includes the new options.""" | ||
# Get the priority field definition | ||
priority_field = self.project_task_model.fields_get(allfields=["priority"])[ | ||
"priority" | ||
] | ||
|
||
# Verify the new priority options are included | ||
expected_options = [("2", "Very High"), ("3", "Most Important")] | ||
for option in expected_options: | ||
self.assertIn( | ||
option, | ||
priority_field["selection"], | ||
f"{option} not found in priority selection", | ||
) | ||
|
||
def test_create_task_with_new_priority(self): | ||
"""Test creating tasks with the new priorities.""" | ||
# Create a task with the new priority "Very High" | ||
task = self.project_task_model.create( | ||
{ | ||
"name": "Test Very High Priority Task", | ||
"priority": "2", | ||
} | ||
) | ||
self.assertEqual(task.priority, "2", "Task priority should be '2' (Very High)") | ||
|
||
# Create a task with the new priority "Most Important" | ||
task = self.project_task_model.create( | ||
{ | ||
"name": "Test Most Important Priority Task", | ||
"priority": "3", | ||
} | ||
) | ||
self.assertEqual( | ||
task.priority, "3", "Task priority should be '3' (Most Important)" | ||
) | ||
|
||
def test_update_priority(self): | ||
"""Test updating task priority.""" | ||
# Create a task with a default priority | ||
task = self.project_task_model.create({"name": "Test Task"}) | ||
self.assertEqual(task.priority, "0", "Default task priority should be '0'") | ||
|
||
# Update the priority to "Very High" | ||
task.write({"priority": "2"}) | ||
self.assertEqual( | ||
task.priority, "2", "Task priority should be updated to '2' (Very High)" | ||
) | ||
|
||
# Update the priority to "Most Important" | ||
task.write({"priority": "3"}) | ||
self.assertEqual( | ||
task.priority, | ||
"3", | ||
"Task priority should be updated to '3' (Most Important)", | ||
) | ||
|
||
def test_invalid_priority(self): | ||
"""Test that an invalid priority value raises an error.""" | ||
with self.assertRaises( | ||
ValueError, msg="Invalid priority should raise ValueError" | ||
): | ||
self.project_task_model.create( | ||
{"name": "Invalid Priority Task", "priority": "99"} | ||
) |