diff --git a/sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.js b/sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.js index 3aefc8303..b689baa3b 100644 --- a/sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.js +++ b/sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.js @@ -17,6 +17,7 @@ patch(FormController.prototype, { // if (this.isAdmin) { // this.props.preventEdit = this.env.inDialog ? false : true; // } + this.orm = useService("orm"); this.actionService =useService("action"); this.props.preventEdit = this.env.inDialog ? false : true; originalSetup.call(this); diff --git a/yuthon_hr_attendance/controllers/applet_attendance.py b/yuthon_hr_attendance/controllers/applet_attendance.py index 95cca9269..1df0c7857 100644 --- a/yuthon_hr_attendance/controllers/applet_attendance.py +++ b/yuthon_hr_attendance/controllers/applet_attendance.py @@ -6,6 +6,7 @@ from geopy.distance import geodesic from datetime import timedelta import json from dateutil.relativedelta import relativedelta + _logger = logging.getLogger(__name__) @@ -21,11 +22,18 @@ class AppletAttendance(Controller): uid = request.session.authenticate(request.env.cr.dbname, login, password) user_id = request.env['res.users'].sudo().browse(uid) employee_id = user_id.with_company(user_id.company_id.id).employee_id - data = {'name': employee_id.name, 'id': user_id.id} - return_data = {'data': data, 'code': 200, 'message': ''} + data = { + 'name': employee_id.name, + 'id': user_id.id, + 'access': ['打卡'], + } + return_data = {'data': data, + 'code': 200, + + 'message': ''} return json.dumps(return_data) - @route('/yuthon/att/today', methods=['POST'], type='http', auth='none', cors='*', csrf=False) + @route('/yuthon/att/today', methods=['POST'], type='http', auth='none', cors='*', csrf=False) def apple_yuthon_att_today(self, **kw): """ 小程序获取当前用户打卡信息 @@ -50,7 +58,8 @@ class AppletAttendance(Controller): return {'state': 'no', 'state_result': result} user_id = request.env(user=SUPERUSER_ID)["res.users"].search([('id', '=', user_id.id)]) employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_id.name)]) - address_id = request.env(user=SUPERUSER_ID)["applet.address"].search([('address_name', '=', employee_id.company_id.name)]) + address_id = request.env(user=SUPERUSER_ID)["applet.address"].search( + [('address_name', '=', employee_id.company_id.name)]) attendance_id = request.env(user=SUPERUSER_ID)["hr.attendance"].search( [('employee_id', '=', employee_id.id), ('current_data', '=', current_data)]) group_id = attendance_id.shift_name @@ -92,7 +101,8 @@ class AppletAttendance(Controller): } return json.dumps(return_data) else: - attendance_id = request.env(user=SUPERUSER_ID)["hr.attendance"].search([('employee_id', '=', employee_id.id), ('current_data', '=', current_data)]) + attendance_id = request.env(user=SUPERUSER_ID)["hr.attendance"].search( + [('employee_id', '=', employee_id.id), ('current_data', '=', current_data)]) check_in = attendance_id.check_in check_out = attendance_id.check_out attendance_class = attendance_id.shift_name @@ -105,7 +115,7 @@ class AppletAttendance(Controller): # 拼接成 datetime 对象 start_datetime = datetime.combine(current_data, datetime.min.time()).replace( hour=start_hour, minute=start_minute, second=0, microsecond=0 - ) # 标准上班打卡时间 + ) # 标准上班打卡时间 end_datetime = datetime.combine(current_data, datetime.min.time()).replace( hour=end_hour, minute=end_minute, second=0, microsecond=0 ) @@ -234,7 +244,8 @@ class AppletAttendance(Controller): current_month_last = datetime(year + 1, 1, 1) - timedelta(days=1) else: current_month_last = datetime(year, month + 1, 1) - timedelta(days=1) - calendar_leaves = request.env(user=SUPERUSER_ID)['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")]) # 少一个search + calendar_leaves = request.env(user=SUPERUSER_ID)['resource.calendar.leaves'].search( + [("calendar_id", "=", "行政考勤工作日")]) # 少一个search # 本月的节假日 holiday_data = self.get_holiday_data(current_month_first.date(), current_month_last.date()) # 本月考勤记录 @@ -302,8 +313,10 @@ class AppletAttendance(Controller): # 格式化实际打卡时间 check_in_str = check_in.strftime('%H:%M:%S') if check_in else '未打卡' check_out_str = check_out.strftime('%H:%M:%S') if check_out else '未打卡' + def get_status_color(status): return 'red' if status in ['迟到', '早退', '未打卡'] else 'green' + check_in_html = f'

{check_in_status}

' check_out_html = f'

{check_out_status}

' @@ -373,13 +386,9 @@ class AppletAttendance(Controller): "shift_days_list": shift_days_list, } - - - - # 水电表接口 - @route('/yuthon/meter/reading', methods=['POST'], type='http', auth='none', cors='*', csrf=False) + @route('/yuthon/meter/reading', methods=['POST'], type='http', auth='none', cors='*', csrf=False) def yuthon_meter_reading(self, **kw): """ 水电表抄表 @@ -394,8 +403,10 @@ class AppletAttendance(Controller): } """ _logger.info("----------------/yuthon/meter/reading---------接口收到响应-------------------------------") - electric_records = request.env(user=SUPERUSER_ID)['property.electric.reading'].search([('reading_state', '=', 'wait')]) - water_records = request.env(user=SUPERUSER_ID)['property.water.reading'].search([('reading_state', '=', 'wait')]) + electric_records = request.env(user=SUPERUSER_ID)['property.electric.reading'].search( + [('reading_state', '=', 'wait')]) + water_records = request.env(user=SUPERUSER_ID)['property.water.reading'].search( + [('reading_state', '=', 'wait')]) result_list = [] # 处理电表记录 for record in electric_records: @@ -427,7 +438,7 @@ class AppletAttendance(Controller): } return json.dumps(return_data) - @route('/yuthon/meter/dosage', methods=['POST'], type='http', auth='none', cors='*', csrf=False) + @route('/yuthon/meter/dosage', methods=['POST'], type='http', auth='none', cors='*', csrf=False) def yuthon_meter_dosage(self, **kw): """ 更新仪表用量 @@ -462,4 +473,4 @@ class AppletAttendance(Controller): 'message': message, } _logger.info(message) - return json.dumps(return_data) \ No newline at end of file + return json.dumps(return_data)