IMP maintenance_repair when making a preventative maintenance, pre-fill inventory locations

This commit is contained in:
Bhoomi
2019-09-03 17:25:51 -04:00
parent ddd07994e5
commit ed984e24e9

View File

@@ -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
})