diff --git a/maintenance_repair/models/maintenance.py b/maintenance_repair/models/maintenance.py index dc096ef0..f806f957 100644 --- a/maintenance_repair/models/maintenance.py +++ b/maintenance_repair/models/maintenance.py @@ -62,7 +62,6 @@ class MaintenanceRequest(models.Model): request.repair_line_ids.action_complete() return True - class MaintenanceRequestRepairLine(models.Model): _name = 'maintenance.request.repair.line' @@ -140,3 +139,26 @@ class MaintenanceRequestRepairLine(models.Model): line.write({'move_id': move.id, 'state': 'done'}) return True + + +class MaintenanceEquipment(models.Model): + _inherit = 'maintenance.equipment' + + def _create_new_request(self, date): + # Added repair_location_id and repair_location_dest_id + # Cannot call super() because it does not return the object + self.ensure_one() + return self.env['maintenance.request'].create({ + 'name': _('Preventive Maintenance - %s') % self.name, + 'request_date': date, + 'schedule_date': date, + 'category_id': self.category_id.id, + 'equipment_id': self.id, + 'maintenance_type': 'preventive', + 'owner_user_id': self.owner_user_id.id, + 'user_id': self.technician_user_id.id, + 'maintenance_team_id': self.maintenance_team_id.id, + 'duration': self.maintenance_duration, + 'repair_location_id': self.maintenance_team_id.repair_location_id.id, + 'repair_location_dest_id': self.maintenance_team_id.repair_location_dest_id.id + })