| 
						
						
							
								
							
						
						
					 | 
					@ -140,20 +140,28 @@ class MrpWorkorder(models.Model): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Boolean: Returns true | 
					 | 
					 | 
					            Boolean: Returns true | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        """ | 
					 | 
					 | 
					        """ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        res = super(MrpWorkorder, self).button_finish() | 
					 | 
					 | 
					        res = super(MrpWorkorder, self).button_finish() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        project = self.env['project.project'].search( | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            [('name', '=', ("MO: {}".format(self.production_id.name)))]) | 
					 | 
					 | 
					        for workorder in self: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        task_id = project.task_ids.search([('name', '=', ( | 
					 | 
					 | 
					            project = self.env['project.project'].search([ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            "{} in {} for {} on {}".format(self.name, self.workcenter_id.name, | 
					 | 
					 | 
					                ('name', '=', f"MO: {workorder.production_id.name}") | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                                           self.product_id.display_name, | 
					 | 
					 | 
					            ], limit=1) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                                           str(self.date_start))))]) | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        task_id.write({ | 
					 | 
					 | 
					            task = project.task_ids.search([ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'allocated_hours': self.duration_expected | 
					 | 
					 | 
					                ('name', '=', ( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    f"{workorder.name} in {workorder.workcenter_id.name} for " | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    f"{workorder.product_id.display_name} on {str(workorder.date_start)}" | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                )) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            ], limit=1) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            task.write({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                'allocated_hours': workorder.duration_expected | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            }) | 
					 | 
					 | 
					            }) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        timesheet = task_id.mapped('timesheet_ids') | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        for rec in timesheet: | 
					 | 
					 | 
					            for rec in task.timesheet_ids: | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                rec.write({ | 
					 | 
					 | 
					                rec.write({ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                'unit_amount': self.duration, | 
					 | 
					 | 
					                    'unit_amount': workorder.duration, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                }) | 
					 | 
					 | 
					                }) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return res | 
					 | 
					 | 
					        return res | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @api.depends('employee_id') | 
					 | 
					 | 
					    @api.depends('employee_id') | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |