| 
						
						
							
								
							
						
						
					 | 
					@ -26,19 +26,28 @@ class TaskChecklist(models.Model): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    name = fields.Char(string='Name') | 
					 | 
					 | 
					    name = fields.Char(string='Name') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    description = fields.Char(string='Description') | 
					 | 
					 | 
					    description = fields.Char(string='Description') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    project_id = fields.Many2one('project.project', string='Project') | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    task_ids = fields.Many2one('project.task', string='Task') | 
					 | 
					 | 
					    task_ids = fields.Many2one('project.task', string='Task') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    project_id = fields.Many2one('project.project', string='Project') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    checklist_ids = fields.One2many('checklist.item', 'checklist_id', string='CheckList Items', required=True) | 
					 | 
					 | 
					    checklist_ids = fields.One2many('checklist.item', 'checklist_id', string='CheckList Items', required=True) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					class ChecklistItem(models.Model): | 
					 | 
					 | 
					class CheckListItem(models.Model): | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    _name = 'checklist.item' | 
					 | 
					 | 
					    _name = 'checklist.item' | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    _description = 'Checklist Item' | 
					 | 
					 | 
					    _description = "Checklist Item" | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    name = fields.Char(required=True) | 
					 | 
					 | 
					    name = fields.Char(required=True) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    sequence = fields.Integer(default=1) | 
					 | 
					 | 
					    sequence = fields.Integer(default=1) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    description = fields.Char() | 
					 | 
					 | 
					    description = fields.Char() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    checklist_id = fields.Many2one('task.checklist') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					class ChecklistItemLine(models.Model): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    _name = 'checklist.item.line' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    _description = 'Checklist Item Line' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    check_list_item_id = fields.Many2one('checklist.item', required=True) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    description = fields.Char() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    projects_id = fields.Many2one('project.task') | 
					 | 
					 | 
					    projects_id = fields.Many2one('project.task') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    checklist_id = fields.Many2one('task.checklist') | 
					 | 
					 | 
					    checklist_id = fields.Many2one('task.checklist') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    state = fields.Selection(string='Status', required=True, readonly=True, copy=False, tracking=True, selection=[ | 
					 | 
					 | 
					    state = fields.Selection(string='Status', required=True, readonly=True, copy=False, tracking=True, selection=[ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -46,7 +55,7 @@ class ChecklistItem(models.Model): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        ('in_progress', 'In Progress'), | 
					 | 
					 | 
					        ('in_progress', 'In Progress'), | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        ('done', 'Done'), | 
					 | 
					 | 
					        ('done', 'Done'), | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        ('cancel', 'Cancelled'), | 
					 | 
					 | 
					        ('cancel', 'Cancelled'), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    ], default='todo',) | 
					 | 
					 | 
					    ], default='todo', ) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    def approve_and_next(self): | 
					 | 
					 | 
					    def approve_and_next(self): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        self.state = 'in_progress' | 
					 | 
					 | 
					        self.state = 'in_progress' | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -67,31 +76,32 @@ class ChecklistProgress(models.Model): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    start_date = fields.Datetime(string='Start Date') | 
					 | 
					 | 
					    start_date = fields.Datetime(string='Start Date') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    end_date = fields.Datetime(string='End Date') | 
					 | 
					 | 
					    end_date = fields.Datetime(string='End Date') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    progress = fields.Float(compute='_compute_progress', string='Progress in %') | 
					 | 
					 | 
					    progress = fields.Float(compute='_compute_progress', string='Progress in %') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    checklist_ids = fields.Many2many('task.checklist', compute='_compute_checklist_ids') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    checklist_id = fields.Many2one('task.checklist') | 
					 | 
					 | 
					    checklist_id = fields.Many2one('task.checklist') | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    checklists = fields.One2many('checklist.item', 'projects_id', string='CheckList Items', required=True) | 
					 | 
					 | 
					    checklists = fields.One2many('checklist.item.line', 'projects_id', string='CheckList Items', required=True) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @api.onchange('checklist_id') | 
					 | 
					 | 
					    @api.onchange('checklist_id') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    def _onchange_project_id(self): | 
					 | 
					 | 
					    def _onchange_project_id(self): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        self.checklists = [] | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        checklist = self.env['task.checklist'].search([('name', '=', self.checklist_id.name)]) | 
					 | 
					 | 
					        checklist = self.env['task.checklist'].search([('name', '=', self.checklist_id.name)]) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        print('task', checklist) | 
					 | 
					 | 
					        self.checklists = False | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        for rec in checklist: | 
					 | 
					 | 
					        self.checklists = [(0, 0, { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            print('rec', rec.checklist_ids) | 
					 | 
					 | 
					            'check_list_item_id': rec.id, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            self.checklists += rec.checklist_ids | 
					 | 
					 | 
					            'state': 'todo', | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            'checklist_id': self.checklist_id.id, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        }) for rec in checklist.checklist_ids] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    def _compute_checklist_ids(self): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        for rec in self: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            self.checklist_ids = self.env['task.checklist'].search([('task_ids', '=', rec.id)]) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    def _compute_progress(self): | 
					 | 
					 | 
					    def _compute_progress(self): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        for rec in self: | 
					 | 
					 | 
					        for rec in self: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            print('recccc', rec) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            total_completed = 0 | 
					 | 
					 | 
					            total_completed = 0 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            for activity in rec.checklists: | 
					 | 
					 | 
					            for activity in rec.checklists: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                print('activity', activity) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                if activity.state in ['cancel', 'done', 'in_progress']: | 
					 | 
					 | 
					                if activity.state in ['cancel', 'done', 'in_progress']: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    print('stage', activity.state) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    total_completed += 1 | 
					 | 
					 | 
					                    total_completed += 1 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            if total_completed: | 
					 | 
					 | 
					            if total_completed: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                print('completed', total_completed) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                rec.progress = float(total_completed) / len(rec.checklists) * 100 | 
					 | 
					 | 
					                rec.progress = float(total_completed) / len(rec.checklists) * 100 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            else: | 
					 | 
					 | 
					            else: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                rec.progress = 0.0 | 
					 | 
					 | 
					                rec.progress = 0.0 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |