Domain filter added

This commit is contained in:
projectsodoo 2021-01-07 16:38:07 +05:30
parent ba9d6bca16
commit ea2202fa23
1 changed files with 8 additions and 5 deletions

View File

@ -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'),