mirror of
https://github.com/bringout/oca-project.git
synced 2026-04-19 01:02:00 +02:00
Move 124 sale modules to oca-sale, create oca-project with 56 project modules from oca-workflow-process
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9eb7ae5807
commit
6094c218b2
2332 changed files with 125826 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
from . import test_project_sprint
|
||||
from . import test_project_project
|
||||
from . import test_project_task
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
from odoo.tests import TransactionCase
|
||||
|
||||
|
||||
class TestProjectProject(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.user_demo = cls.env.ref("base.user_demo")
|
||||
cls.user_admin = cls.env.ref("base.user_admin")
|
||||
|
||||
cls.project = cls.env["project.project"].create(
|
||||
{"name": "Test Project", "user_id": cls.user_demo.id}
|
||||
)
|
||||
cls.sprint = cls.env["project.sprint"].create(
|
||||
{
|
||||
"name": "Test Sprint",
|
||||
"user_ids": [(4, cls.user_demo.id)],
|
||||
"project_id": cls.project.id,
|
||||
"date_start": "2024-08-30",
|
||||
"date_end": "2024-09-15",
|
||||
}
|
||||
)
|
||||
cls.task_1 = cls.env["project.task"].create(
|
||||
{
|
||||
"name": "Test Task 1",
|
||||
"project_id": cls.project.id,
|
||||
"user_ids": [(4, cls.user_demo.id)],
|
||||
"sprint_id": cls.sprint.id,
|
||||
}
|
||||
)
|
||||
cls.task_2 = cls.env["project.task"].create(
|
||||
{
|
||||
"name": "Test Task 2",
|
||||
"project_id": cls.project.id,
|
||||
"user_ids": [(4, cls.user_demo.id)],
|
||||
}
|
||||
)
|
||||
|
||||
def test_backlog_count(self):
|
||||
self.project._compute_backlog_count()
|
||||
self.assertEqual(self.project.backlog_count, 1)
|
||||
self.task_2.sprint_id = self.sprint.id
|
||||
self.project._compute_backlog_count()
|
||||
self.assertEqual(self.project.backlog_count, 0)
|
||||
|
||||
def test_sprint_count(self):
|
||||
self.project._compute_sprint_count()
|
||||
self.assertEqual(self.project.sprint_count, 1)
|
||||
|
||||
def test_action_sprints(self):
|
||||
action = self.project.action_sprints()
|
||||
self.assertEqual(action["res_model"], "project.sprint")
|
||||
self.assertEqual(
|
||||
action["domain"],
|
||||
["|", ("project_id", "=", self.project.id), ("project_id", "=", False)],
|
||||
)
|
||||
self.assertEqual(action["context"], {"default_project_id": self.project.id})
|
||||
|
||||
def test_action_backlog(self):
|
||||
action = self.project.action_backlog()
|
||||
self.assertEqual(action["res_model"], "project.task")
|
||||
self.assertEqual(
|
||||
action["domain"],
|
||||
[
|
||||
("project_id", "=", self.project.id),
|
||||
("sprint_id", "=", False),
|
||||
("kanban_state", "!=", "done"),
|
||||
],
|
||||
)
|
||||
self.assertEqual(action["context"], {"default_project_id": self.project.id})
|
||||
|
||||
def test_action_sprint_timeline(self):
|
||||
action = self.project.action_sprint_timeline()
|
||||
self.assertEqual(action["res_model"], "project.task")
|
||||
self.assertEqual(
|
||||
action["domain"],
|
||||
[("project_id", "=", self.project.id), ("sprint_id", "!=", False)],
|
||||
)
|
||||
self.assertEqual(
|
||||
action["context"],
|
||||
{"default_project_id": self.project.id, "no_create": True},
|
||||
)
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
from freezegun import freeze_time
|
||||
|
||||
from odoo.tests import TransactionCase
|
||||
|
||||
|
||||
class TestProjectSprint(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.user_demo = cls.env.ref("base.user_demo")
|
||||
cls.user_admin = cls.env.ref("base.user_admin")
|
||||
cls.project = cls.env["project.project"].create(
|
||||
{"name": "Test Project", "user_id": cls.user_demo.id}
|
||||
)
|
||||
cls.sprint = cls.env["project.sprint"].create(
|
||||
{
|
||||
"name": "Test Sprint",
|
||||
"user_ids": [(4, cls.user_demo.id)],
|
||||
"project_id": cls.project.id,
|
||||
"date_start": "2024-08-28",
|
||||
"date_end": "2024-09-15",
|
||||
}
|
||||
)
|
||||
cls.task = cls.env["project.task"].create(
|
||||
{
|
||||
"name": "Test Task",
|
||||
"project_id": cls.project.id,
|
||||
"user_ids": [(4, cls.user_demo.id)],
|
||||
"sprint_id": cls.sprint.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_state_project_sprint(self):
|
||||
self.assertEqual(self.sprint.state, "draft")
|
||||
self.sprint.action_start()
|
||||
self.assertEqual(self.sprint.state, "in_progress")
|
||||
self.sprint.action_done()
|
||||
self.assertEqual(self.sprint.state, "done")
|
||||
|
||||
@freeze_time("2024-08-30")
|
||||
def test_check_project_update(self):
|
||||
self.sprint_2 = self.env["project.sprint"].create(
|
||||
{
|
||||
"name": "Test Sprint 2",
|
||||
"user_ids": [(4, self.user_demo.id)],
|
||||
"project_id": self.project.id,
|
||||
"date_start": "2024-08-10",
|
||||
"date_end": "2024-08-28",
|
||||
"state": "in_progress",
|
||||
}
|
||||
)
|
||||
self.sprint.state = "draft"
|
||||
self.sprint.cron_update_sprint_state()
|
||||
self.assertEqual(self.sprint.state, "in_progress")
|
||||
self.assertEqual(self.sprint_2.state, "done")
|
||||
|
||||
def test_task_count(self):
|
||||
self.assertEqual(self.sprint.tasks_count, 1)
|
||||
self.task.sprint_id = False
|
||||
self.sprint._compute_tasks_count()
|
||||
self.assertEqual(self.sprint.tasks_count, 0)
|
||||
|
||||
def test_compute_end_date(self):
|
||||
self.assertEqual(self.sprint.date_end.strftime("%Y-%m-%d"), "2024-09-15")
|
||||
self.sprint.date_option = "1_months"
|
||||
self.sprint._compute_date_end()
|
||||
self.assertEqual(self.sprint.date_end.strftime("%Y-%m-%d"), "2024-09-28")
|
||||
self.sprint.date_option = "custom"
|
||||
self.sprint._compute_date_end()
|
||||
self.assertEqual(self.sprint.date_end.strftime("%Y-%m-%d"), "2024-08-29")
|
||||
|
||||
def test_action_task(self):
|
||||
action = self.sprint.action_tasks()
|
||||
self.assertEqual(action["res_model"], "project.task")
|
||||
self.assertEqual(action["domain"], [("sprint_id", "=", self.sprint.id)])
|
||||
self.assertEqual(
|
||||
action["context"],
|
||||
{
|
||||
"default_project_id": self.project.id,
|
||||
"default_sprint_id": self.sprint.id,
|
||||
},
|
||||
)
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import TransactionCase
|
||||
|
||||
|
||||
class TestProjectTask(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.user_demo = cls.env.ref("base.user_demo")
|
||||
cls.user_admin = cls.env.ref("base.user_admin")
|
||||
cls.project = cls.env["project.project"].create(
|
||||
{"name": "Test Project", "user_id": cls.user_demo.id}
|
||||
)
|
||||
cls.sprint = cls.env["project.sprint"].create(
|
||||
{
|
||||
"name": "Test Sprint",
|
||||
"user_ids": [(4, cls.user_demo.id)],
|
||||
"project_id": cls.project.id,
|
||||
"date_start": "2021-01-01",
|
||||
"date_end": "2021-01-15",
|
||||
}
|
||||
)
|
||||
cls.task = cls.env["project.task"].create(
|
||||
{
|
||||
"name": "Test Task",
|
||||
"project_id": cls.project.id,
|
||||
"user_ids": [(4, cls.user_demo.id)],
|
||||
"sprint_id": cls.sprint.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_user_ids(self):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.task.user_ids = [(4, self.user_admin.id)]
|
||||
|
||||
def test_onchange_sprint_id(self):
|
||||
self.task._onchange_sprint_id()
|
||||
self.assertEqual(len(self.task.user_ids), 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue