diff --git a/room/models/room_booking.py b/room/models/room_booking.py
index da7847834..4dbfbcb15 100644
--- a/room/models/room_booking.py
+++ b/room/models/room_booking.py
@@ -127,7 +127,6 @@ class RoomBooking(models.Model):
else:
par.partner_ids = [(5, 0, 0)]
-
def meet_notice(self):
if self.is_notice:
for internal in self.room_users_ids:
diff --git a/yuthon_hr_attendance/__init__.py b/yuthon_hr_attendance/__init__.py
index 8c67f893b..15b511f68 100644
--- a/yuthon_hr_attendance/__init__.py
+++ b/yuthon_hr_attendance/__init__.py
@@ -3,3 +3,4 @@
from . import models
from . import controllers
+from . import wizard
diff --git a/yuthon_hr_attendance/__manifest__.py b/yuthon_hr_attendance/__manifest__.py
index 6c9f31f68..319699b79 100644
--- a/yuthon_hr_attendance/__manifest__.py
+++ b/yuthon_hr_attendance/__manifest__.py
@@ -24,6 +24,7 @@
'views/resource_calendar_leaves_views.xml',
'views/attendance_iot_datas.xml',
'views/attendance_iot_manager_views.xml',
+ 'views/attendance_iot_views.xml',
'views/overtime_approval.xml',
'views/go_approval.xml',
'views/duty_approval.xml',
@@ -34,8 +35,8 @@
'views/holiday_manage.xml',
'views/holiday_manage_balance.xml',
'views/attendance_iot_datas.xml',
- 'views/yuthon_mqtt_service.xml',
'views/all_attendance_menu.xml',
+ 'wizard/attendance_iot_manager_wizard_views.xml',
],
'installable': True,
'application': True,
diff --git a/yuthon_hr_attendance/controllers/kaoqin_test.py b/yuthon_hr_attendance/controllers/kaoqin_test.py
index 378c71c5d..f4bec6f20 100644
--- a/yuthon_hr_attendance/controllers/kaoqin_test.py
+++ b/yuthon_hr_attendance/controllers/kaoqin_test.py
@@ -4,12 +4,9 @@ from odoo import models, fields, api, http, SUPERUSER_ID, _
class BusController(Controller):
-
def get_equipment_company(self, sn):
sn_address = {
'RLM-00111018': '地址1',
- 'RLM-00111019': '地址2',
- 'RLM-00111010': '地址3',
}
return sn_address[sn]
@@ -29,7 +26,6 @@ class BusController(Controller):
print("---------------------------------------------测试成功---------------------------------------")
return {"Result": 0, "Msg": "添加成功"}
- #
# @route('/api/v1/user/inf_photo', methods=['POST'], type='json', auth='public')
# def get_model_definitions(self):
# name = request.jsonrequest.get('sn') # 姓名
@@ -70,6 +66,7 @@ class BusController(Controller):
'image_1920': data.get('photo'),
})
attendance_iot.create({
+ 'data_selection': "api",
'attendance_number': data.get('sn'),
'attendance_address': self.get_equipment_company(data.get('sn')),
'employee_id': employee_id.id,
diff --git a/yuthon_hr_attendance/models/__init__.py b/yuthon_hr_attendance/models/__init__.py
index 5996422af..eff7cc554 100644
--- a/yuthon_hr_attendance/models/__init__.py
+++ b/yuthon_hr_attendance/models/__init__.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from . import hr_attendance
+from . import attendance_iot
from . import resource_calendar_leaves
from . import hr_employee
from . import overtime_approval
diff --git a/yuthon_hr_attendance/models/attendance_iot.py b/yuthon_hr_attendance/models/attendance_iot.py
new file mode 100644
index 000000000..b28f7c069
--- /dev/null
+++ b/yuthon_hr_attendance/models/attendance_iot.py
@@ -0,0 +1,13 @@
+from odoo import api, fields, models, tools
+from odoo.exceptions import ValidationError
+
+
+class AttendanceIot(models.Model):
+ _name = 'attendance.iot'
+ _description = '考勤机设备'
+ _rec_name = 'name'
+
+ name = fields.Char(string="设备号")
+ attendance_address = fields.Char(string="设备地址")
+ broker = fields.Char(string='服务器地址/ip')
+ port = fields.Char(string='端口号')
diff --git a/yuthon_hr_attendance/models/attendance_iot_datas.py b/yuthon_hr_attendance/models/attendance_iot_datas.py
index 275af7010..3f71d699b 100644
--- a/yuthon_hr_attendance/models/attendance_iot_datas.py
+++ b/yuthon_hr_attendance/models/attendance_iot_datas.py
@@ -6,7 +6,6 @@ class AttendanceIotDatas(models.Model):
_name = 'attendance.iot.datas'
_description = '上传识别记录'
-
employee_id = fields.Many2one('hr.employee', string='人员')
attendance_date = fields.Datetime(string='打卡时间')
- attendance_number = fields.Char(string="设备号")
+ attendance_iot_id = fields.Many2one('attendance.iot', string="设备号")
diff --git a/yuthon_hr_attendance/models/attendance_iot_manager.py b/yuthon_hr_attendance/models/attendance_iot_manager.py
index 64d4f745d..b3fe1b2b2 100644
--- a/yuthon_hr_attendance/models/attendance_iot_manager.py
+++ b/yuthon_hr_attendance/models/attendance_iot_manager.py
@@ -12,14 +12,30 @@ class AttendanceIotManager(models.Model):
_name = 'attendance.iot.manager'
_description = "考勤机管理"
- attendance_number = fields.Char(string="设备号")
+ attendance_iot_id = fields.Many2one('attendance.iot', string="设备号")
attendance_address = fields.Char(string="设备地址")
employee_id = fields.Many2one('hr.employee', string="员工")
- broker = fields.Char(string='服务器地址/ip')
- port = fields.Char(string='端口号')
+ id_valid = fields.Date(string="数据有效期")
+ data_selection = fields.Selection([('mqtt', 'mqtt'), ('api', 'api')], default="mqtt", string="数据类型")
+
+ def action_attendance_iot_manager(self):
+ return {
+ "type": "ir.actions.act_window",
+ "name": "批量导入考勤机",
+ "res_model": "attendance.iot.manager.wizard",
+ "view_mode": "form",
+ "target": "new",
+ }
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ for vals in vals_list:
+ if vals['data_selection'] == 'mqtt':
+ self.mqtt_request(self, vals['attendance_number'], 'addUser')
+ return super().create(vals_list)
def mqtt_request(self, attendance_number, data):
- reuqired_params = self.get_required_params(data.get('cmd'))
+ reuqired_params = self.get_required_params(data)
if any(reuqired_param not in data.keys() for reuqired_param in reuqired_params):
raise UserError(f'缺少必填参数,请确认: {",".join(reuqired_params)}')
mqtt_config = self.get_mqtt_config()
diff --git a/yuthon_hr_attendance/models/holiday_manage.py b/yuthon_hr_attendance/models/holiday_manage.py
index eeaa893a0..d53332776 100644
--- a/yuthon_hr_attendance/models/holiday_manage.py
+++ b/yuthon_hr_attendance/models/holiday_manage.py
@@ -16,7 +16,7 @@ class HolidayManage(models.Model):
department_ids = fields.Many2many('hr.department', string='部门范围')
employee_ids = fields.Many2many('hr.employee', string='人员范围')
users_role_ids = fields.Many2many('soong.user.role', string='角色范围')
- holiday_users_ids = fields.Many2many('res.users', string="申请假期人员", compute="compute_room_users_ids", store=True)
+ holiday_users_ids = fields.Many2many('res.users', string="申请假期人员", compute="compute_holiday_users_ids", store=True)
is_limit = fields.Boolean(string="新员工请假是否限制", help='入职即可请假')
leave_time = fields.Selection(selection=[(str(i), str(i)) for i in range(1, 13)], string="入职月份", help='入职时长小于此月份时,不可申请此假期')
diff --git a/yuthon_hr_attendance/security/ir.model.access.csv b/yuthon_hr_attendance/security/ir.model.access.csv
index 6502aa02d..8a569e601 100644
--- a/yuthon_hr_attendance/security/ir.model.access.csv
+++ b/yuthon_hr_attendance/security/ir.model.access.csv
@@ -9,8 +9,11 @@ access_holidays_approval,holidays.approval,model_holidays_approval,base.group_us
access_remove_holiday_approval,remove.holiday.approval,model_remove_holiday_approval,base.group_user,1,1,1,1
access_card_approval,card.approval,model_card_approval,base.group_user,1,1,1,1
access_holiday_manage,holiday_manage,model_holiday_manage,base.group_user,1,1,1,1
+access_attendance_iot,attendance_iot,model_attendance_iot,base.group_user,1,1,1,1
access_attendance_iot_manager,attendance_iot_manager,model_attendance_iot_manager,base.group_user,1,1,1,1
+access_attendance_iot_manager_wizard,attendance_iot_manager_wizard,model_attendance_iot_manager_wizard,base.group_user,1,1,1,1
access_holiday_manage_balance,holiday_manage_balance,model_holiday_manage_balance,base.group_user,1,1,1,1
access_attendance_iot_datas,attendance_iot_datas,model_attendance_iot_datas,base.group_user,1,1,1,1
+
diff --git a/yuthon_hr_attendance/views/all_attendance_menu.xml b/yuthon_hr_attendance/views/all_attendance_menu.xml
index 19058faeb..00c7d12e3 100644
--- a/yuthon_hr_attendance/views/all_attendance_menu.xml
+++ b/yuthon_hr_attendance/views/all_attendance_menu.xml
@@ -26,12 +26,12 @@
parent="holiday_manage_menu_root" action="holiday_manage_type_action" sequence="1"/>
-
+
-
diff --git a/yuthon_hr_attendance/views/attendance_iot_datas.xml b/yuthon_hr_attendance/views/attendance_iot_datas.xml
index 3f8019070..646f6da7d 100644
--- a/yuthon_hr_attendance/views/attendance_iot_datas.xml
+++ b/yuthon_hr_attendance/views/attendance_iot_datas.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/yuthon_hr_attendance/views/attendance_iot_manager_views.xml b/yuthon_hr_attendance/views/attendance_iot_manager_views.xml
index fc5c04649..45004e72c 100644
--- a/yuthon_hr_attendance/views/attendance_iot_manager_views.xml
+++ b/yuthon_hr_attendance/views/attendance_iot_manager_views.xml
@@ -5,11 +5,11 @@
attendance.iot.manager
-
+
-
-
-
+
+
+
@@ -20,7 +20,7 @@
-
+
@@ -32,7 +32,15 @@
tree,form
- { "search_default_attendance_number":1, }
+ { "search_default_attendance_iot_id":1, }
+
+
+ 批量录入考勤机
+
+
+ code
+ action = model.action_attendance_iot_manager()
+
\ No newline at end of file
diff --git a/yuthon_hr_attendance/views/attendance_iot_views.xml b/yuthon_hr_attendance/views/attendance_iot_views.xml
new file mode 100644
index 000000000..73f536e3f
--- /dev/null
+++ b/yuthon_hr_attendance/views/attendance_iot_views.xml
@@ -0,0 +1,21 @@
+
+
+
+ 考勤机设备管理
+ attendance.iot
+
+
+
+
+
+
+
+
+
+
+
+ 考勤机设备管理
+ attendance.iot
+ tree,form
+
+
\ No newline at end of file
diff --git a/yuthon_hr_attendance/views/holiday_manage.xml b/yuthon_hr_attendance/views/holiday_manage.xml
index 34b4de1a8..501533598 100644
--- a/yuthon_hr_attendance/views/holiday_manage.xml
+++ b/yuthon_hr_attendance/views/holiday_manage.xml
@@ -25,7 +25,7 @@
- />
+
diff --git a/yuthon_hr_attendance/views/inherit_hr_employee_views.xml b/yuthon_hr_attendance/views/inherit_hr_employee_views.xml
index b479a17c5..197b23551 100644
--- a/yuthon_hr_attendance/views/inherit_hr_employee_views.xml
+++ b/yuthon_hr_attendance/views/inherit_hr_employee_views.xml
@@ -9,8 +9,10 @@
-
+
+
+
diff --git a/yuthon_hr_attendance/wizard/__init__.py b/yuthon_hr_attendance/wizard/__init__.py
new file mode 100644
index 000000000..1fdee93bc
--- /dev/null
+++ b/yuthon_hr_attendance/wizard/__init__.py
@@ -0,0 +1 @@
+from . import attendance_iot_manager_wizard
\ No newline at end of file
diff --git a/yuthon_hr_attendance/wizard/attendance_iot_manager_wizard.py b/yuthon_hr_attendance/wizard/attendance_iot_manager_wizard.py
new file mode 100644
index 000000000..07bbe1605
--- /dev/null
+++ b/yuthon_hr_attendance/wizard/attendance_iot_manager_wizard.py
@@ -0,0 +1,32 @@
+from odoo import api, fields, models, tools
+from odoo.exceptions import ValidationError
+
+
+class AttendanceIotManagerWizard(models.TransientModel):
+ _name = 'attendance.iot.manager.wizard'
+ _description = '批量导入考勤用户数据弹窗'
+
+ attendance_iot_id = fields.Many2one('attendance.iot', string="设备号")
+ department_ids = fields.Many2many('hr.department', string='部门范围')
+ employee_ids = fields.Many2many('hr.employee', string='人员范围')
+ users_role_ids = fields.Many2many('soong.user.role', string='角色范围')
+ iot_users_ids = fields.Many2many('res.users', string="人员", compute="compute_iot_users_ids", store=True)
+
+ @api.depends('department_ids', 'employee_ids', 'users_role_ids')
+ def compute_iot_users_ids(self):
+ users_role_list = department_users_list = []
+ # 部门人员
+ for depart in self.department_ids:
+ department_users_data = self.env['hr.employee'].search([('department_id', '=', depart.id)])
+ department_users_list = [de.user_id.id for de in department_users_data]
+ # 人员
+ employee_users_list = self.employee_ids.user_id.ids
+ # 角色人员
+ for user_id in self.users_role_ids:
+ department_users_data = self.env['hr.employee'].search([('user_role_id', '=', user_id.id)])
+ users_role_list = [ro.user_id.id for ro in department_users_data]
+ publish_user_list = department_users_list + employee_users_list + users_role_list
+ self.iot_users_ids = [(6, 0, publish_user_list)]
+
+ def confirm(self):
+ pass
diff --git a/yuthon_hr_attendance/wizard/attendance_iot_manager_wizard_views.xml b/yuthon_hr_attendance/wizard/attendance_iot_manager_wizard_views.xml
new file mode 100644
index 000000000..496796972
--- /dev/null
+++ b/yuthon_hr_attendance/wizard/attendance_iot_manager_wizard_views.xml
@@ -0,0 +1,28 @@
+
+
+
+ 批量导入考勤用户数据弹窗
+ attendance.iot.manager.wizard
+
+
+
+
+
\ No newline at end of file
diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml
index a75f83f74..ca2b8cf0f 100644
--- a/yuthon_work_brand/views/hr_menus.xml
+++ b/yuthon_work_brand/views/hr_menus.xml
@@ -5,7 +5,7 @@
-
+
@@ -13,11 +13,11 @@
-
+
-
+
@@ -48,10 +48,10 @@
parent="hr_recruitment_setting_menu_board"
action="hr_recruitment.action_hr_recruitment_configuration"
sequence="1"/>
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+