diff --git a/project_forecast/models/project.py b/project_forecast/models/project.py
index 34c0473..7860de7 100755
--- a/project_forecast/models/project.py
+++ b/project_forecast/models/project.py
@@ -15,6 +15,11 @@ class Project(models.Model):
raise UserError(_('You cannot delete a project containing plannings. You can either delete all the project\'s forecasts and then delete the project or simply deactivate the project.'))
return super(Project, self).unlink()
+ def action_view_project_forecast_action_from_project(self):
+ action = self.env["ir.actions.actions"]._for_xml_id("project_forecast.project_forecast_action_from_project")
+ action['context'] = {'default_project_id': self.id}
+ return action
+
class Task(models.Model):
_inherit = 'project.task'
diff --git a/project_forecast/models/project_forecast.py b/project_forecast/models/project_forecast.py
index 6c61e71..19a0419 100755
--- a/project_forecast/models/project_forecast.py
+++ b/project_forecast/models/project_forecast.py
@@ -50,7 +50,7 @@ class PlanningShift(models.Model):
else:
self.task_id.project_id = self.project_id
- @api.onchange('employee_id')
+ """@api.onchange('employee_id')
def _onchange_employee_id(self):
domain = []
if self.employee_id and not self.employee_id.user_id:
@@ -74,13 +74,30 @@ class PlanningShift(models.Model):
result = {
'domain': {'project_id': domain},
}
- return result
+ return result"""
@api.onchange('project_id')
def _onchange_project_id(self):
domain = [] if not self.project_id else [('project_id', '=', self.project_id.id)]
+ manager_id = []
+ user_ids = []
+ consul_project_ids = []
+ if self.project_id:
+ consul_ids = self.env['project.sale.line.employee.map'].search([('project_id', '=', self.project_id.id)])
+ consul_project_ids = [val.employee_id.id for val in consul_ids]
+ print("consul_project_ids", consul_project_ids)
+ if self.project_id and self.project_id.user_id:
+ manager_id = self.env['hr.employee'].search([('user_id', '=', self.project_id.user_id.id)]).ids
+ print("manager_id", manager_id)
+ if self.project_id and self.project_id.privacy_visibility in ('employees', 'portal'):
+ user_ids = self.env['hr.employee'].search([('user_id', '!=', False)]).ids
+ if self.project_id and self.project_id.privacy_visibility == 'followers':
+ print("project_all_emp_ids", self.project_id.allowed_internal_user_ids, self.project_id.allowed_internal_user_ids.ids)
+ user_ids = self.env['hr.employee'].search([('user_id', 'in', self.project_id.allowed_internal_user_ids.ids)]).ids
+ project_all_emp_ids = manager_id + user_ids + consul_project_ids
+ print("project_all_emp_idsproject_all_emp_ids", project_all_emp_ids, domain)
result = {
- 'domain': {'task_id': domain},
+ 'domain': {'task_id': domain, 'employee_id': [('id', 'in', project_all_emp_ids)]},
}
if self.project_id != self.task_id.project_id:
# reset task when changing project
diff --git a/project_forecast/views/planning_views.xml b/project_forecast/views/planning_views.xml
index 9b7fce4..b7dd760 100755
--- a/project_forecast/views/planning_views.xml
+++ b/project_forecast/views/planning_views.xml
@@ -7,9 +7,11 @@