[IMP] sale_(project): improve ux' for project

Purpose of this PR to improve the generic usage of project app

So in this commit done the following changes:
 - when a project is archived, the 'tasks' stat button should
   count/show archived tasks
 - when delete project it's milestone should also be deleted automatically.
 - project.task > blocked by notebook: it should be possible to select tasks
   in projects that are not allowing 'task dependencies'
 - project.task portal form view: hide the description if it is empty

task-2853991

closes odoo/odoo#94138

Related: odoo/enterprise#28654
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
hiroh-odoo
2022-09-16 14:25:04 +02:00
committed by Prakash Prajapati
parent ee3ff4064e
commit 85a485034b
3 changed files with 16 additions and 8 deletions
+14 -6
View File
@@ -236,18 +236,25 @@ class Project(models.Model):
project.doc_count = docs_count.get(project.id, 0)
def _compute_task_count(self):
task_data = self.env['project.task']._read_group(
[('project_id', 'in', self.ids),
('is_closed', '=', False)],
['project_id', 'display_project_id:count'], ['project_id'])
domain = [('project_id', 'in', self.ids), ('is_closed', '=', False)]
fields = ['project_id', 'display_project_id:count']
groupby = ['project_id']
task_data = self.env['project.task']._read_group(domain, fields, groupby)
result_wo_subtask = defaultdict(int)
result_with_subtasks = defaultdict(int)
for data in task_data:
result_wo_subtask[data['project_id'][0]] += data['display_project_id']
result_with_subtasks[data['project_id'][0]] += data['project_id_count']
task_all_data = self.env['project.task'].with_context(active_test=False)._read_group(domain, fields, groupby)
all_tasks_wo_subtasks = defaultdict(int)
for data in task_all_data:
all_tasks_wo_subtasks[data['project_id'][0]] += data['display_project_id']
for project in self:
project.task_count = result_wo_subtask[project.id]
project.task_count_with_subtasks = result_with_subtasks[project.id]
if not project.active:
project.task_count = all_tasks_wo_subtasks[project.id]
def _default_stage_id(self):
# Since project stages are order by sequence first, this should fetch the one with the lowest sequence number.
@@ -749,6 +756,7 @@ class Project(models.Model):
context = ast.literal_eval(context)
context.update({
'create': self.active,
'active_test': self.active
})
action['context'] = context
return action
@@ -1193,10 +1201,10 @@ class Task(models.Model):
# Tracking of this field is done in the write function
depend_on_ids = fields.Many2many('project.task', relation="task_dependencies_rel", column1="task_id",
column2="depends_on_id", string="Blocked By", tracking=True, copy=False,
domain="[('allow_task_dependencies', '=', True), ('id', '!=', id)]")
domain="[('project_id', '!=', False), ('id', '!=', id)]")
dependent_ids = fields.Many2many('project.task', relation="task_dependencies_rel", column1="depends_on_id",
column2="task_id", string="Block", copy=False,
domain="[('allow_task_dependencies', '=', True), ('id', '!=', id)]")
domain="[('project_id', '!=', False), ('id', '!=', id)]")
dependent_tasks_count = fields.Integer(string="Dependent Tasks", compute='_compute_dependent_tasks_count')
is_blocked = fields.Boolean(compute='_compute_is_blocked', store=True, recursive=True)
+1 -1
View File
@@ -15,7 +15,7 @@ class ProjectMilestone(models.Model):
return self.env.context.get('default_project_id') or self.env.context.get('active_id')
name = fields.Char(required=True)
project_id = fields.Many2one('project.project', required=True, default=_get_default_project_id)
project_id = fields.Many2one('project.project', required=True, default=_get_default_project_id, ondelete='cascade')
deadline = fields.Date(tracking=True, copy=False)
is_reached = fields.Boolean(string="Reached", default=False, copy=False)
reached_date = fields.Date(compute='_compute_reached_date', store=True)
@@ -320,7 +320,7 @@
</div>
<div class="row" t-if="task.description or task.attachment_ids">
<div t-if="task.description" t-attf-class="col-12 col-lg-7 mb-4 mb-md-0 {{'col-lg-7' if task.attachment_ids else 'col-lg-12'}}">
<div t-if="not is_html_empty(task.description)" t-attf-class="col-12 col-lg-7 mb-4 mb-md-0 {{'col-lg-7' if task.attachment_ids else 'col-lg-12'}}">
<hr class="mb-1"/>
<div class="d-flex my-2">
<strong>Description</strong>