changes
This commit is contained in:
@@ -1501,6 +1501,13 @@ class AuthorizerPortal(CustomerPortal):
|
||||
accuracy=accuracy,
|
||||
)
|
||||
|
||||
# Push location to remote instances for cross-instance visibility
|
||||
try:
|
||||
request.env['fusion.task.sync.config'].sudo()._push_technician_location(
|
||||
user.id, latitude, longitude, accuracy or 0)
|
||||
except Exception:
|
||||
pass # Non-blocking: sync failure should not block task action
|
||||
|
||||
location_ctx = {
|
||||
'action_latitude': latitude,
|
||||
'action_longitude': longitude,
|
||||
@@ -1870,6 +1877,25 @@ class AuthorizerPortal(CustomerPortal):
|
||||
_logger.warning(f"Location log error: {e}")
|
||||
return {'success': False}
|
||||
|
||||
@http.route('/my/technician/clock-status', type='json', auth='user', website=True)
|
||||
def technician_clock_status(self, **kw):
|
||||
"""Check if the current technician is clocked in.
|
||||
|
||||
Returns {clocked_in: bool} so the JS background logger can decide
|
||||
whether to track location. Replaces the fixed 9-6 hour window.
|
||||
"""
|
||||
if not self._check_technician_access():
|
||||
return {'clocked_in': False}
|
||||
try:
|
||||
emp = request.env['hr.employee'].sudo().search([
|
||||
('user_id', '=', request.env.user.id),
|
||||
], limit=1)
|
||||
if emp and emp.attendance_state == 'checked_in':
|
||||
return {'clocked_in': True}
|
||||
except Exception:
|
||||
pass
|
||||
return {'clocked_in': False}
|
||||
|
||||
@http.route('/my/technician/settings/start-location', type='json', auth='user', website=True)
|
||||
def technician_save_start_location(self, address='', **kw):
|
||||
"""Save the technician's personal start location."""
|
||||
|
||||
Reference in New Issue
Block a user