From ea2202fa2348cf8ac5896f8e2a35acd0e1ffa32d Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Thu, 7 Jan 2021 16:38:07 +0530 Subject: [PATCH] Domain filter added --- cor_custom/models/analytic.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cor_custom/models/analytic.py b/cor_custom/models/analytic.py index d851d9c..ad1aae3 100755 --- a/cor_custom/models/analytic.py +++ b/cor_custom/models/analytic.py @@ -16,7 +16,7 @@ class AccountAnalyticLine(models.Model): end_time = fields.Float(string='End Time', digits=(16, 2)) unit_amount = fields.Float('Duration', default=0.0) - """@api.onchange('employee_id') + @api.onchange('employee_id') def _onchange_employee_id(self): domain = [] if self.employee_id and self.employee_id.user_id: @@ -34,14 +34,17 @@ class AccountAnalyticLine(models.Model): result = { 'domain': {'project_id': domain}, } - return result""" + return result - """@api.onchange('project_id') + @api.onchange('project_id') def _onchange_project_id(self): domain = [] if not self.project_id else [('project_id', '=', self.project_id.id)] + cuser = [] manager_id = [] user_ids = [] consul_project_ids = [] + if not self.project_id: + cuser = self.env['hr.employee'].search([('user_id','=', self.env.user.id)]).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] @@ -52,14 +55,14 @@ class AccountAnalyticLine(models.Model): if self.project_id and self.project_id.privacy_visibility == 'followers': 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 + project_all_emp_ids = cuser + manager_id + user_ids + consul_project_ids result = { '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 self.task_id = False - return result""" + return result _sql_constraints = [ ('check_start_time_lower_than_24', 'CHECK(start_time <= 24)', 'You cannot have a start hour greater than 24'),