Skip to content

Commit

Permalink
[ADD]project_ux:state change in project tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
mav-adhoc committed May 3, 2024
1 parent 1432d84 commit c68f0ac
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 1 deletion.
3 changes: 3 additions & 0 deletions project_ux/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Several improvements to project:
- 2 new filters: "Is Task"& "Is Sub-Task"
- 1 new agroupation: "Parent-Task"
#. Re-incorporates the wizard that allows to select an existing task to be converted as a sub-task in the sub-task tab (in the migration to 17, when you press on "Add line" in the sub-task tab, you could only create new sub-tasks, not convert the existing tasks to sub-tasks)
#. Incorporates a tab inside the project form view called "Task stages" that allows to select (or create) the task stages that will apply to that project.
#. Incorporates an option inside the tasks stage configurations that allows to automatically set a state to the tasks when they are moved to these stages.
#. Re-incorporate the field is_closed in the tasks, under the label "Folded in kanban"

Installation
============
Expand Down
3 changes: 2 additions & 1 deletion project_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Project UX',
'version': "17.0.1.0.0",
'version': "17.0.1.1.0",
'category': 'Project Management',
'sequence': 14,
'author': 'ADHOC SA',
Expand All @@ -34,6 +34,7 @@
'data': [
'views/project_task_views.xml',
'views/project_project_views.xml',
'views/project_task_type_views.xml',
],
'demo': [
],
Expand Down
56 changes: 56 additions & 0 deletions project_ux/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,66 @@ msgstr "Tarea padre"
msgid "Task"
msgstr "Tarea"

#. module: project_ux
#: model:ir.model,name:project_ux.model_project_task
msgid "Folded in Kanban"
msgstr "Plegado en Kanban"

#. module: project_ux
#: model:ir.model.fields,help:project_ux.field_project_task__dont_send_stage_email
msgid ""
"When the task's stage changes, if the stage has an automatic template set, "
"no email will be send. After the stage changes, this value returns to False "
"so that new stage changes will send emails."
msgstr ""

#. module: project_ux
#: model_terms:ir.ui.view,arch_db:project_ux.edit_project
msgid "Tasks Stages"
msgstr "Etapas de tareas"

#. module: project_ux
#: model:ir.model,name:project_ux.model_project_task_type
msgid "State Change"
msgstr "Cambio de Estado"

#. module: project_ux
#: model:ir.model,name:project_ux.model_project_task_type
msgid "Task State"
msgstr "Estado de Tarea"

#. module: project_ux
#: model:ir.model.fields.selection,name:project_ux.selection__project_task_type_task_state_approved
#, python-format
msgid "Approved"
msgstr "Aprobado"

#. module: project_ux
#: model:ir.model.fields.selection,name:project_ux.selection__project_task_type_task_state_approved
#, python-format
msgid "In Progress"
msgstr "En Progreso"

#. module: project_ux
#: model:ir.model.fields.selection,name:project_ux.selection__project_task_type_task_state_approved
#, python-format
msgid "Done"
msgstr "Hecho"

#. module: project_ux
#: model:ir.model.fields.selection,name:project_ux.selection__project_task_type_task_state_approved
#, python-format
msgid "Waiting"
msgstr "Esperando"

#. module: project_ux
#: model:ir.model.fields.selection,name:project_ux.selection__project_task_type_task_state_approved
#, python-format
msgid "Canceled"
msgstr "Cancelado"

#. module: project_ux
#: model:ir.model.fields.selection,name:project_ux.selection__project_task_type_task_state_approved
#, python-format
msgid "Changes Requested"
msgstr "Cambios Requeridos"
1 change: 1 addition & 0 deletions project_ux/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import project_task_type
from . import project_task
22 changes: 22 additions & 0 deletions project_ux/models/project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
##############################################################################
from odoo import models, fields, api

CLOSED_STATES = {
'1_done': 'Done',
'1_canceled': 'Canceled',
}

class Task(models.Model):
_inherit = 'project.task'
Expand All @@ -15,6 +19,7 @@ class Task(models.Model):
"no email will be send. After the stage changes, this value returns to False so that "
"new stage changes will send emails."
)
is_closed = fields.Boolean(related="stage_id.fold", string="Folded in Kanban", store=True, index=True)

def _track_template(self, changes):
task = self[0]
Expand All @@ -28,3 +33,20 @@ def _track_template(self, changes):
res.pop('stage_id')
task.dont_send_stage_email = False
return res

@api.depends('stage_id', 'depend_on_ids.state', 'project_id.allow_task_dependencies')
def _compute_state(self):
for task in self:
dependent_open_tasks = []
if task.allow_task_dependencies:
dependent_open_tasks = [dependent_task for dependent_task in task.depend_on_ids if dependent_task.state not in CLOSED_STATES]
# if one of the blocking task is in a blocking state
if dependent_open_tasks:
# 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)
if task.state not in CLOSED_STATES:
task.state = '04_waiting_normal'
# if the task as no blocking dependencies and is in waiting_normal, the task goes back to in progress
elif task.state not in CLOSED_STATES:
task.state = '01_in_progress'
if task.stage_id.task_state:
task.state = task.stage_id.task_state
15 changes: 15 additions & 0 deletions project_ux/models/project_task_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields

class ProjectTaskType(models.Model):
_inherit = 'project.task.type'

state_change = fields.Boolean(
default=False,
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"
)

task_state = fields.Selection(selection=lambda self: self.env['project.task'].fields_get(allfields=['state'])['state']['selection'])
18 changes: 18 additions & 0 deletions project_ux/views/project_project_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<field name="user_id" position="attributes">
<attribute name="groups"></attribute>
</field>
<xpath expr="//notebook//page[1]" position="after">
<page string="Tasks Stages" name="project_stages">
<field name="type_ids">
<tree>
<field name="sequence" optional="show"/>
<field name="name"/>
<field name="mail_template_id" optional="hide"/>
<field name="rating_template_id" optional="hide" groups="project.group_project_rating"/>
<field name="project_ids" optional="show" widget="many2many_tags" options="{'color_field': 'color'}" />
<field name="fold" optional="show"/>
<field name="user_id" optional="show"/>
</tree>
</field>
</page>
</xpath>
<xpath expr="//button[@name='project_update_all_action']" position="attributes">
<attribute name="groups">project.group_project_user</attribute>
</xpath>
Expand Down
19 changes: 19 additions & 0 deletions project_ux/views/project_task_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<odoo>

<record id="task_type_edit_inherited" model="ir.ui.view">
<field name="name">project.task.type.form.inherited</field>
<field name="model">project.task.type</field>
<field name="inherit_id" ref="project.task_type_edit"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='project_ids']" position="after">
<label for="state_change"/>
<div class="o_row">
<field name="state_change"/>
<field name="task_state" invisible='state_change == False'/>
</div>
</xpath>
</field>
</record>

</odoo>

0 comments on commit c68f0ac

Please sign in to comment.