This commit is contained in:
Admin
2026-01-11 23:18:48 +08:00
parent e04109aa56
commit 87536178cb
2 changed files with 24 additions and 1 deletions
+23 -1
View File
@@ -3,7 +3,7 @@ import urllib.parse
from odoo.http import Controller, request, route
from datetime import datetime, timedelta
from odoo import models, fields, api, http, SUPERUSER_ID, _
import logging
import logging, json
_logger = logging.getLogger(__name__)
@@ -142,3 +142,25 @@ class BusController(Controller):
employee.with_context(iot_sync=True).write({'avatar_image': photo})
return {"Result": 0, "Msg": "更新成功"}
@http.route('/phone/attendance/list', type='http', auth="none", csrf=False, cors='*')
def phone_attendance_list(self, **kw):
data = request.env['attendance.iot'].sudo().search([]).read()
return json.dumps({'data': data, 'code': 200, 'message': ''})
@http.route('/phone/attendance/list', type='http', auth="none", csrf=False, cors='*')
def phone_attendance_list(self, **kw):
employee_id = request.env['hr.employee'].sudo().search([('user_id.id', '=', int(kw.get('employee_id')))])
data = request.env['attendance.iot'].sudo().search([]).read()
return json.dumps({'data': data, 'code': 200, 'message': ''})
@http.route('/phone/attendance/operation', type='http', auth="none", csrf=False, cors='*')
def phone_attendance_operation(self, **kw):
equipment_id = kw.get('equipment_id')
equipment = request.env['attendance.iot'].sudo().browse(int(equipment_id))
action = kw.get('action')
if action == 'open':
equipment.action_send_open_door_sigle()
else:
equipment.action_send_close_door_sigle()
return json.dumps({'data': '', 'code': 200, 'message': ''})
+1
View File
@@ -90,6 +90,7 @@ class AttendanceIot(models.Model):
'value': 'on'
}, ensure_ascii=False)
}])
def action_send_close_door_sigle(self):
for record in self:
self.env['iot.message'].create([{