Skip to content

Commit 3117c25

Browse files
authored
temp rebasing PR 130 (eb2bd70)
2 parents db59f18 + eb2bd70 commit 3117c25

File tree

7 files changed

+102
-98
lines changed

7 files changed

+102
-98
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
exclude: |
66
(?x)
7-
7+
88
# We don't want to mess with tool-generated files
99
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
1010
# Library files can have extraneous formatting (even minimized)
Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
{
2-
'name': 'Project My Tasks By Stage',
3-
'version': "18.0.1.0.0",
4-
'category': 'Services/Project',
5-
'sequence': 50,
6-
'summary': '',
7-
'author': 'ADHOC SA',
8-
'website': 'www.adhoc.com.ar',
9-
'license': 'AGPL-3',
10-
'images': [
2+
"name": "Project My Tasks By Stage",
3+
"version": "18.0.1.0.0",
4+
"category": "Services/Project",
5+
"sequence": 50,
6+
"summary": "",
7+
"author": "ADHOC SA",
8+
"website": "www.adhoc.com.ar",
9+
"license": "AGPL-3",
10+
"images": [],
11+
"depends": [
12+
"project",
1113
],
12-
'depends': [
13-
'project',
14+
"data": [
15+
"views/project_task_views.xml",
1416
],
15-
'data': [
16-
'views/project_task_views.xml',
17-
],
18-
'installable': True,
19-
'auto_install': False,
20-
'application': False,
17+
"installable": True,
18+
"auto_install": False,
19+
"application": False,
2120
}

project_ux/__manifest__.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,25 @@
1818
#
1919
##############################################################################
2020
{
21-
'name': 'Project UX',
22-
'version': "18.0.1.0.0",
23-
'category': 'Project Management',
24-
'sequence': 14,
25-
'author': 'ADHOC SA',
26-
'website': 'www.adhoc.com.ar',
27-
'license': 'AGPL-3',
28-
'images': [
21+
"name": "Project UX",
22+
"version": "18.0.1.0.0",
23+
"category": "Project Management",
24+
"sequence": 14,
25+
"author": "ADHOC SA",
26+
"website": "www.adhoc.com.ar",
27+
"license": "AGPL-3",
28+
"images": [],
29+
"depends": [
30+
"project",
31+
"project_enterprise",
2932
],
30-
'depends': [
31-
'project',
32-
'project_enterprise',
33+
"data": [
34+
"views/project_task_views.xml",
35+
"views/project_project_views.xml",
36+
"views/project_task_type_views.xml",
3337
],
34-
'data': [
35-
'views/project_task_views.xml',
36-
'views/project_project_views.xml',
37-
'views/project_task_type_views.xml',
38-
],
39-
'demo': [
40-
],
41-
'installable': True,
42-
'auto_install': False,
43-
'application': False,
38+
"demo": [],
39+
"installable": True,
40+
"auto_install": False,
41+
"application": False,
4442
}

project_ux/models/project_task.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,59 @@
22
# For copyright and license notices, see __manifest__.py file in module root
33
# directory
44
##############################################################################
5-
from odoo import models, fields, api
5+
from odoo import api, fields, models
66

77
CLOSED_STATES = {
8-
'1_done': 'Done',
9-
'1_canceled': 'Canceled',
8+
"1_done": "Done",
9+
"1_canceled": "Canceled",
1010
}
1111

12+
1213
class Task(models.Model):
13-
_inherit = 'project.task'
14+
_inherit = "project.task"
1415

1516
dont_send_stage_email = fields.Boolean(
1617
string="Don't Send Stage Email",
1718
default=False,
1819
help="When the task's stage changes, if the stage has an automatic template set, "
1920
"no email will be send. After the stage changes, this value returns to False so that "
20-
"new stage changes will send emails."
21+
"new stage changes will send emails.",
2122
)
2223
is_closed = fields.Boolean(related="stage_id.fold", string="Folded in Kanban", index=True)
2324

2425
def _track_template(self, changes):
2526
task = self[0]
2627
res = super()._track_template(changes)
27-
if 'stage_id' in changes and task.stage_id.mail_template_id:
28-
res['stage_id'] = (task.stage_id.mail_template_id, {
29-
'message_type': 'comment',
30-
'auto_delete_keep_log': False,
31-
'subtype_id': self.env['ir.model.data']._xmlid_to_res_id('mail.mt_comment'),
32-
'email_layout_xmlid': 'mail.mail_notification_light'})
33-
if 'stage_id' in res and task.dont_send_stage_email and task.stage_id.mail_template_id:
34-
res.pop('stage_id')
28+
if "stage_id" in changes and task.stage_id.mail_template_id:
29+
res["stage_id"] = (
30+
task.stage_id.mail_template_id,
31+
{
32+
"message_type": "comment",
33+
"auto_delete_keep_log": False,
34+
"subtype_id": self.env["ir.model.data"]._xmlid_to_res_id("mail.mt_comment"),
35+
"email_layout_xmlid": "mail.mail_notification_light",
36+
},
37+
)
38+
if "stage_id" in res and task.dont_send_stage_email and task.stage_id.mail_template_id:
39+
res.pop("stage_id")
3540
task.dont_send_stage_email = False
3641
return res
3742

38-
@api.depends('stage_id', 'depend_on_ids.state', 'project_id.allow_task_dependencies')
43+
@api.depends("stage_id", "depend_on_ids.state", "project_id.allow_task_dependencies")
3944
def _compute_state(self):
4045
for task in self:
4146
dependent_open_tasks = []
4247
if task.allow_task_dependencies:
43-
dependent_open_tasks = [dependent_task for dependent_task in task.depend_on_ids if dependent_task.state not in CLOSED_STATES]
48+
dependent_open_tasks = [
49+
dependent_task for dependent_task in task.depend_on_ids if dependent_task.state not in CLOSED_STATES
50+
]
4451
# if one of the blocking task is in a blocking state
4552
if dependent_open_tasks:
4653
# here we check that the blocked task is not already in a closed state (if the task is already done we don't put it in waiting state)
4754
if task.state not in CLOSED_STATES:
48-
task.state = '04_waiting_normal'
55+
task.state = "04_waiting_normal"
4956
# if the task as no blocking dependencies and is in waiting_normal, the task goes back to in progress
5057
elif task.state not in CLOSED_STATES:
51-
task.state = '01_in_progress'
58+
task.state = "01_in_progress"
5259
if task.stage_id.task_state:
5360
task.state = task.stage_id.task_state

project_ux/models/project_task_type.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22
# For copyright and license notices, see __manifest__.py file in module root
33
# directory
44
##############################################################################
5-
from odoo import models, fields, api
5+
from odoo import api, fields, models
66
from odoo.exceptions import UserError
77

8+
89
class ProjectTaskType(models.Model):
9-
_inherit = 'project.task.type'
10+
_inherit = "project.task.type"
1011

1112
state_change = fields.Boolean(
1213
default=False,
13-
help="When the task's stage changes, if the state change is checked it will change the state of the task into the state selected"
14+
help="When the task's stage changes, if the state change is checked it will change the state of the task into the state selected",
1415
)
1516

16-
task_state = fields.Selection(selection=lambda self: self.env['project.task'].fields_get(allfields=['state'])['state']['selection'])
17+
task_state = fields.Selection(
18+
selection=lambda self: self.env["project.task"].fields_get(allfields=["state"])["state"]["selection"]
19+
)
1720

18-
@api.constrains('state_change', 'task_state')
21+
@api.constrains("state_change", "task_state")
1922
def _check_task_state(self):
2023
for record in self:
2124
if record.state_change and not record.task_state:
22-
raise UserError("The state to which the task should change cannot be empty if 'state change' is checked")
25+
raise UserError(
26+
"The state to which the task should change cannot be empty if 'state change' is checked"
27+
)
Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
from odoo.tests.common import TransactionCase
22

3-
class TestTaskModel(TransactionCase):
43

4+
class TestTaskModel(TransactionCase):
55
def setUp(self):
66
super(TestTaskModel, self).setUp()
7-
self.Task = self.env['project.task']
8-
self.Stage = self.env['project.task.type']
9-
self.Template = self.env['mail.template']
7+
self.Task = self.env["project.task"]
8+
self.Stage = self.env["project.task.type"]
9+
self.Template = self.env["mail.template"]
1010

11-
mail_template = self.Template.create({
12-
'name': 'Test Template',
13-
'email_from': 'test@example.com',
14-
'subject': 'Test Subject',
15-
'body_html': '<p>Test Body</p>'
16-
})
11+
mail_template = self.Template.create(
12+
{
13+
"name": "Test Template",
14+
"email_from": "test@example.com",
15+
"subject": "Test Subject",
16+
"body_html": "<p>Test Body</p>",
17+
}
18+
)
1719

18-
self.test_stage = self.Stage.create({
19-
'name': 'Test Stage',
20-
'mail_template_id': mail_template.id
21-
})
20+
self.test_stage = self.Stage.create({"name": "Test Stage", "mail_template_id": mail_template.id})
2221

23-
self.test_task = self.Task.create({
24-
'name': 'Test Task',
25-
'stage_id': self.test_stage.id,
26-
'state': '01_in_progress',
27-
})
22+
self.test_task = self.Task.create(
23+
{
24+
"name": "Test Task",
25+
"stage_id": self.test_stage.id,
26+
"state": "01_in_progress",
27+
}
28+
)
2829

2930
def test_compute_state_with_dependencies(self):
3031
"""Test _compute_state method when dependencies are present"""
31-
dependent_task = self.Task.create({
32-
'name': 'Dependent Task',
33-
'stage_id': self.test_stage.id,
34-
'state': '01_in_progress'
35-
})
36-
self.test_task.write({'depend_on_ids': [(4, dependent_task.id)], 'allow_task_dependencies': True})
32+
dependent_task = self.Task.create(
33+
{"name": "Dependent Task", "stage_id": self.test_stage.id, "state": "01_in_progress"}
34+
)
35+
self.test_task.write({"depend_on_ids": [(4, dependent_task.id)], "allow_task_dependencies": True})
3736
self.test_task._compute_state()
38-
self.assertEqual(self.test_task.state, '04_waiting_normal')
39-
dependent_task.state = '1_done'
37+
self.assertEqual(self.test_task.state, "04_waiting_normal")
38+
dependent_task.state = "1_done"
4039
self.test_task._compute_state()
41-
self.assertEqual(self.test_task.state, '01_in_progress')
40+
self.assertEqual(self.test_task.state, "01_in_progress")
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
from odoo.tests.common import TransactionCase
21
from odoo.exceptions import UserError
2+
from odoo.tests.common import TransactionCase
33

4-
class TestProjectTaskType(TransactionCase):
54

5+
class TestProjectTaskType(TransactionCase):
66
def setUp(self):
77
super(TestProjectTaskType, self).setUp()
8-
self.ProjectTaskType = self.env['project.task.type']
8+
self.ProjectTaskType = self.env["project.task.type"]
99

1010
def test_state_change_constraint_error(self):
1111
"""Test that UserError is raised when state_change is True and task_state is empty"""
1212
with self.assertRaises(UserError):
13-
self.ProjectTaskType.create({
14-
'name': 'Test Task Type',
15-
'state_change': True,
16-
'task_state': ''
17-
})
13+
self.ProjectTaskType.create({"name": "Test Task Type", "state_change": True, "task_state": ""})

0 commit comments

Comments
 (0)