|
2 | 2 | # For copyright and license notices, see __manifest__.py file in module root |
3 | 3 | # directory |
4 | 4 | ############################################################################## |
5 | | -from odoo import models, fields, api |
| 5 | +from odoo import api, fields, models |
6 | 6 |
|
7 | 7 | CLOSED_STATES = { |
8 | | - '1_done': 'Done', |
9 | | - '1_canceled': 'Canceled', |
| 8 | + "1_done": "Done", |
| 9 | + "1_canceled": "Canceled", |
10 | 10 | } |
11 | 11 |
|
| 12 | + |
12 | 13 | class Task(models.Model): |
13 | | - _inherit = 'project.task' |
| 14 | + _inherit = "project.task" |
14 | 15 |
|
15 | 16 | dont_send_stage_email = fields.Boolean( |
16 | 17 | string="Don't Send Stage Email", |
17 | 18 | default=False, |
18 | 19 | help="When the task's stage changes, if the stage has an automatic template set, " |
19 | 20 | "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.", |
21 | 22 | ) |
22 | 23 | is_closed = fields.Boolean(related="stage_id.fold", string="Folded in Kanban", index=True) |
23 | 24 |
|
24 | 25 | def _track_template(self, changes): |
25 | 26 | task = self[0] |
26 | 27 | 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") |
35 | 40 | task.dont_send_stage_email = False |
36 | 41 | return res |
37 | 42 |
|
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") |
39 | 44 | def _compute_state(self): |
40 | 45 | for task in self: |
41 | 46 | dependent_open_tasks = [] |
42 | 47 | 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 | + ] |
44 | 51 | # if one of the blocking task is in a blocking state |
45 | 52 | if dependent_open_tasks: |
46 | 53 | # 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) |
47 | 54 | if task.state not in CLOSED_STATES: |
48 | | - task.state = '04_waiting_normal' |
| 55 | + task.state = "04_waiting_normal" |
49 | 56 | # if the task as no blocking dependencies and is in waiting_normal, the task goes back to in progress |
50 | 57 | elif task.state not in CLOSED_STATES: |
51 | | - task.state = '01_in_progress' |
| 58 | + task.state = "01_in_progress" |
52 | 59 | if task.stage_id.task_state: |
53 | 60 | task.state = task.stage_id.task_state |
0 commit comments