timesheet validation for project start and end date
This commit is contained in:
parent
150562ea65
commit
9a89a881c7
|
@ -26,7 +26,9 @@ class AccountAnalyticLine(models.Model):
|
|||
return res
|
||||
|
||||
def _domain_project_id(self):
|
||||
domain = [('allow_timesheets', '=', True), ('is_sub_project', '=', False)]
|
||||
today = fields.Date.today()
|
||||
#domain = [('allow_timesheets', '=', True), ('is_sub_project', '=', False)]
|
||||
domain = [('allow_timesheets', '=', True), ('is_sub_project', '=', False),('date', '>=', today),('date_start', '<=', today)]
|
||||
if not self.user_has_groups('hr_timesheet.group_timesheet_manager'):
|
||||
return expression.AND([domain,
|
||||
['|', ('privacy_visibility', '!=', 'followers'),
|
||||
|
@ -77,21 +79,26 @@ class AccountAnalyticLine(models.Model):
|
|||
def _onchange_employee_id(self):
|
||||
project_manager_grp = self.env.ref('project.group_project_manager').users.ids
|
||||
project_user_grp = self.env.ref('project.group_project_user').users.ids
|
||||
today = fields.Date.today()
|
||||
domain = []
|
||||
if self.employee_id and self.employee_id.user_id and self.employee_id.user_id.id in project_manager_grp:
|
||||
all_projects = self.env['project.project'].search([('allow_timesheets', '=', True),
|
||||
('is_sub_project', '=', False)]).ids
|
||||
('is_sub_project', '=', False),
|
||||
('date', '>=', today),('date_start', '<=', today)]).ids
|
||||
domain = [('id', 'in', all_projects)]
|
||||
else:
|
||||
if self.employee_id and self.employee_id.user_id and self.employee_id.user_id.id in project_user_grp:
|
||||
manager_id = self.env['project.project'].search(
|
||||
[('user_id', '=', self.employee_id.user_id.id), ('allow_timesheets', '=', True),
|
||||
('date', '>=', today),('date_start', '<=', today),
|
||||
('is_sub_project', '=', False)]).ids
|
||||
emp_project_ids = self.env['project.project'].search(
|
||||
[('privacy_visibility', 'in', ('employees', 'portal')), ('allow_timesheets', '=', True),
|
||||
('date', '>=', today),('date_start', '<=', today),
|
||||
('is_sub_project', '=', False)]).ids
|
||||
project_ids = self.env['project.project'].search(
|
||||
[('privacy_visibility', '=', 'followers'), ('allow_timesheets', '=', True),
|
||||
('date', '>=', today),('date_start', '<=', today),
|
||||
('is_sub_project', '=', False),
|
||||
('allowed_internal_user_ids', 'in', self.employee_id.user_id.id)]).ids
|
||||
consul_ids = self.env['project.sale.line.employee.map'].search([('employee_id', '=', self.employee_id.id)])
|
||||
|
|
Loading…
Reference in New Issue