This commit is contained in:
gsinghpal
2026-02-25 09:40:41 -05:00
parent 0e1aebe60b
commit e71bc503f9
69 changed files with 7537 additions and 82 deletions

View File

@@ -2474,3 +2474,69 @@ class AuthorizerPortal(CustomerPortal):
_logger.info(f"Attached video to assessment {assessment.reference}")
except Exception as e:
_logger.warning(f"Failed to attach video to assessment {assessment.reference}: {e}")
# =================================================================
# RENTAL PICKUP INSPECTION (added by fusion_rental)
# =================================================================
@http.route(
'/my/technician/rental-inspection/<int:task_id>',
type='http', auth='user', website=True,
)
def rental_inspection_page(self, task_id, **kw):
"""Render the rental pickup inspection form for the technician."""
user = request.env.user
task = request.env['fusion.technician.task'].sudo().browse(task_id)
if (
not task.exists()
or task.technician_id.id != user.id
or task.task_type != 'pickup'
):
return request.redirect('/my')
return request.render(
'fusion_rental.portal_rental_inspection',
{
'task': task,
'order': task.sale_order_id,
'page_name': 'rental_inspection',
},
)
@http.route(
'/my/technician/rental-inspection/<int:task_id>/submit',
type='json', auth='user', methods=['POST'],
)
def rental_inspection_submit(self, task_id, **kwargs):
"""Save the rental inspection results."""
user = request.env.user
task = request.env['fusion.technician.task'].sudo().browse(task_id)
if (
not task.exists()
or task.technician_id.id != user.id
or task.task_type != 'pickup'
):
return {'success': False, 'error': 'Access denied.'}
condition = kwargs.get('condition', '')
notes = kwargs.get('notes', '')
photo_ids = kwargs.get('photo_ids', [])
if not condition:
return {'success': False, 'error': 'Please select a condition.'}
vals = {
'rental_inspection_condition': condition,
'rental_inspection_notes': notes,
'rental_inspection_completed': True,
}
if photo_ids:
vals['rental_inspection_photo_ids'] = [(6, 0, photo_ids)]
task.write(vals)
return {
'success': True,
'message': 'Inspection saved. You can now complete the task.',
}