summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAndrea Grazioso (agr-odoo) <agr@odoo.com>2020-10-12 12:49:44 +0000
committerAndrea Grazioso (agr-odoo) <agr@odoo.com>2020-10-26 07:42:09 +0000
commit29a2b863b7abe3639fc569d643005db171c2ca5b (patch)
treefef1709b1d8b321805c0a98860815dcba4763601 /addons
parentce6f6fb4e04746d28e1b959d50f50a855c7a3049 (diff)
[FIX] sale_timesheet: fix task creation when no tasks
Create a sale order with a service configured with - Service Invoicing Policy: Timesheets on tasks - Service Tracking: Create a new project but no task Save and confirm. Access the project and the tasks via smart button. Create a new task. The task will not be saved under the current project because there is no data reference in context. opw-2355547 closes odoo/odoo#60690 X-original-commit: 51ce1d6ca479b4d851eacef70212bf890588e1c7 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/sale_timesheet/models/project_overview.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/sale_timesheet/models/project_overview.py b/addons/sale_timesheet/models/project_overview.py
index c752f67ea2a..d3b58dd3097 100644
--- a/addons/sale_timesheet/models/project_overview.py
+++ b/addons/sale_timesheet/models/project_overview.py
@@ -446,12 +446,14 @@ class Project(models.Model):
late_tasks_domain = [('project_id', 'in', self.ids), ('date_deadline', '<', fields.Date.to_string(fields.Date.today())), ('date_end', '=', False)]
overtime_tasks_domain = [('project_id', 'in', self.ids), ('overtime', '>', 0), ('planned_hours', '>', 0)]
- # filter out all the projects that have no tasks
- task_projects_ids = self.env['project.task'].read_group([('project_id', 'in', self.ids)], ['project_id'], ['project_id'])
- task_projects_ids = [p['project_id'][0] for p in task_projects_ids]
+ if len(self) == 1:
+ tasks_context = {**tasks_context, 'default_project_id': self.id}
+ elif len(self):
+ task_projects_ids = self.env['project.task'].read_group([('project_id', 'in', self.ids)], ['project_id'], ['project_id'])
+ task_projects_ids = [p['project_id'][0] for p in task_projects_ids]
+ if len(task_projects_ids) == 1:
+ tasks_context = {**tasks_context, 'default_project_id': task_projects_ids[0]}
- if len(task_projects_ids) == 1:
- tasks_context = {**tasks_context, 'default_project_id': task_projects_ids[0]}
stat_buttons.append({
'name': _('Tasks'),
'count': sum(self.mapped('task_count')),