diff --git a/attendance_iot/__manifest__.py b/attendance_iot/__manifest__.py
index 7652b0588..1003adabb 100644
--- a/attendance_iot/__manifest__.py
+++ b/attendance_iot/__manifest__.py
@@ -14,6 +14,7 @@
'data': [
'security/ir.model.access.csv',
'views/attendance_iot_datas.xml',
+ 'views/attendance_iot_user_views.xml',
'views/attendance_iot_manager_views.xml',
'views/attendance_iot_views.xml',
'views/inherit_hr_employee_views.xml',
diff --git a/attendance_iot/controllers/kaoqin_test.py b/attendance_iot/controllers/kaoqin_test.py
index b772649d0..c185cc778 100644
--- a/attendance_iot/controllers/kaoqin_test.py
+++ b/attendance_iot/controllers/kaoqin_test.py
@@ -1,54 +1,11 @@
+from venv import create
+
from odoo.http import Controller, request, route
from datetime import datetime
from odoo import models, fields, api, http, SUPERUSER_ID, _
class BusController(Controller):
- def get_equipment_company(self, sn):
- sn_address = {
- 'RLM-00111018': '地址1',
- }
- return sn_address[sn]
-
- @route('/api/v1/record/face', methods=['POST'], type='json', auth='none', csrf=False)
- def get_model_definitions(self):
- """
- 用户通过考勤机识别,写入考勤数据
- :return:
- """
- data = request.httprequest.json['logs'][0]
- user_name = data.get('user_name')
- employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_name)])
- request.env(user=SUPERUSER_ID)["hr.attendance"].create({
- 'employee_id': employee_id.id,
- 'check_in': datetime.strptime(data.get('recog_time'), '%Y-%m-%d %H:%M:%S')
- })
- 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') # 姓名
- phone = request.jsonrequest.get('content') # 电话
- print(name, phone)
- return {
- "Result": 0,
- "Msg": "更新成功"
- }
-
- # 员工识别接口
- @route('/api/v1/stranger', methods=['POST'], type='json', auth='none')
- def get_model_definitions(self):
- data = request.httprequest.json.get('logs')[0]
- user_name = data['user_name']
- request.env["hr.employee"].create({
- 'name': user_name + 'stranger',
- })
- print("---------------------------------------------测试成功---------------------------------------")
- return {
- "Result": 0,
- "Msg": "更新成功"
- }
@route('/api/v1/addFace', methods=['POST'], type='json', auth='none', csrf=False)
def get_model_kaoqin(self):
@@ -58,19 +15,26 @@ class BusController(Controller):
"""
data = request.httprequest.json
user_name = data.get('name')
+ name = data.get('sn')
# validity_period = datetime.strptime(data.get('validity_period'), '%Y-%m-%d').date()
- employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_name)])
- attendance_iot = request.env(user=SUPERUSER_ID)["attendance.iot.manager"]
- if not attendance_iot.search([('employee_id', '=', employee_id.id), ('attendance_number', '=', data.get('sn'))]):
- employee_id.write({
+ attendance_iot_id = request.env["attendance.iot"].search([('name', '=', name)])
+ if not attendance_iot_id:
+ request.env["attendance.iot"].create({
+ 'name': name,
+ })
+ employee = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_name)])
+ # 判断员工是否绑定多台设备
+ if employee and attendance_iot_id not in employee.attendance_iot_ids.mapped('attendance_iot_id'):
+ employee.write({
'image_1920': data.get('photo'),
+ 'attendance_iot_ids': [(0, 0, {
+ 'employee_id': employee.id,
+ 'attendance_address': self.get_equipment_company(data.get('sn')),
+ 'attendance_iot_id': attendance_iot_id.id
+ })]
})
- 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,
- })
+
+
print("---------------------------------------------测试成功---------------------------------------")
return {"Result": 0, "Msg": "添加成功"}
@@ -81,15 +45,18 @@ class BusController(Controller):
:return:
"""
data = request.httprequest.json
- user_name = data.get('logs').get('user_id')
- employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('user_id', '=', user_name.id)])
- attendance_iot = request.env(user=SUPERUSER_ID)["attendance.iot.datas"]
- if not attendance_iot.search(
- [('employee_id', '=', employee_id.id), ('attendance_number', '=', data.get('sn'))]):
- attendance_iot.create({
- 'attendance_number': data.get('sn'),
- 'attendance_date': data.get('logs').get('recog_time'),
+ user_id = data.get('logs')[0].get('user_id')
+ employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('user_id', '=', user_id.id)])
+ recog_time_str = data.get('logs')[0].get("recog_time")
+ checkin_time = datetime.strptime(recog_time_str, "%Y-%m-%d %H:%M:%S")
+ attendance_iot_id = request.env(user=SUPERUSER_ID)["attendance.iot"].search([('name', '=', data.get('sn'))])
+ if employee_id:
+ request.env(user=SUPERUSER_ID)["hr.attendance.details"].create({
'employee_id': employee_id.id,
+ 'checkin_time': checkin_time,
+ 'source': 'iot',
+ 'attendance_iot_id': attendance_iot_id.id,
+ 'location_title': data.get('logs')[0].get("location").get('address'),
})
print("---------------------------------------------测试成功---------------------------------------")
return {"Result": 0, "Msg": "添加成功"}
diff --git a/attendance_iot/models/__init__.py b/attendance_iot/models/__init__.py
index 6ecccf0e1..8b3a38af1 100644
--- a/attendance_iot/models/__init__.py
+++ b/attendance_iot/models/__init__.py
@@ -1,4 +1,5 @@
from . import hr_employee
+from . import attendance_iot_user
from . import attendance_iot
from . import attendance_iot_datas
from . import attendance_iot_manager
diff --git a/attendance_iot/models/attendance_iot.py b/attendance_iot/models/attendance_iot.py
index b28f7c069..9e4c3d949 100644
--- a/attendance_iot/models/attendance_iot.py
+++ b/attendance_iot/models/attendance_iot.py
@@ -11,3 +11,5 @@ class AttendanceIot(models.Model):
attendance_address = fields.Char(string="设备地址")
broker = fields.Char(string='服务器地址/ip')
port = fields.Char(string='端口号')
+ id_valid = fields.Datetime(string="设备有效期")
+
diff --git a/attendance_iot/models/attendance_iot_manager.py b/attendance_iot/models/attendance_iot_manager.py
index b3fe1b2b2..2d43dac3c 100644
--- a/attendance_iot/models/attendance_iot_manager.py
+++ b/attendance_iot/models/attendance_iot_manager.py
@@ -14,8 +14,6 @@ class AttendanceIotManager(models.Model):
attendance_iot_id = fields.Many2one('attendance.iot', string="设备号")
attendance_address = fields.Char(string="设备地址")
- employee_id = fields.Many2one('hr.employee', string="员工")
- id_valid = fields.Date(string="数据有效期")
data_selection = fields.Selection([('mqtt', 'mqtt'), ('api', 'api')], default="mqtt", string="数据类型")
def action_attendance_iot_manager(self):
@@ -29,9 +27,10 @@ class AttendanceIotManager(models.Model):
@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')
+ pass
+ # 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):
@@ -88,3 +87,19 @@ class AttendanceIotManager(models.Model):
_logger.info(f"操作失败,返回错误码: {res.get('code')}")
client.disconnect()
+ def employee_message(self):
+ domain = [('attendance_iot_id', '=', self.attendance_iot_id.id)]
+ return {
+ 'name': '员工列表',
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'attendance.iot.user',
+ 'view_mode': 'tree',
+ 'domain': domain,
+ 'target': 'current'
+ }
+
+
+
+
+
+
diff --git a/attendance_iot/models/attendance_iot_user.py b/attendance_iot/models/attendance_iot_user.py
new file mode 100644
index 000000000..b469e4e83
--- /dev/null
+++ b/attendance_iot/models/attendance_iot_user.py
@@ -0,0 +1,13 @@
+from odoo import api, fields, models, tools
+from odoo.exceptions import ValidationError
+
+
+class AttendanceIotUser(models.Model):
+ _name = 'attendance.iot.user'
+
+ attendance_iot_id = fields.Many2one('attendance.iot', string="设备号")
+ attendance_address = fields.Char(string="设备地址")
+ employee_id = fields.Many2one('hr.employee', string="员工")
+ department_id = fields.Many2one(related='employee_id.department_id', string="部门")
+ company_id = fields.Many2one(related='employee_id.company_id', string="公司", store=True)
+ id_valid = fields.Date(string="有效日期")
diff --git a/attendance_iot/models/hr_employee.py b/attendance_iot/models/hr_employee.py
index 57ff9a2cf..67a137fff 100644
--- a/attendance_iot/models/hr_employee.py
+++ b/attendance_iot/models/hr_employee.py
@@ -6,4 +6,4 @@ class HrEmployee(models.Model):
_inherit = "hr.employee"
_description = "考勤机和用户信息的绑定"
- attendance_iot_ids = fields.One2many('attendance.iot.manager', 'employee_id', string="考勤机信息")
+ attendance_iot_ids = fields.One2many('attendance.iot.user', 'employee_id', string="考勤机信息")
diff --git a/attendance_iot/security/ir.model.access.csv b/attendance_iot/security/ir.model.access.csv
index c146197a7..4570dc0aa 100644
--- a/attendance_iot/security/ir.model.access.csv
+++ b/attendance_iot/security/ir.model.access.csv
@@ -2,4 +2,5 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
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_attendance_iot_datas,attendance_iot_datas,model_attendance_iot_datas,base.group_user,1,1,1,1
\ No newline at end of file
+access_attendance_iot_datas,attendance_iot_datas,model_attendance_iot_datas,base.group_user,1,1,1,1
+access_attendance_iot_user,attendance_iot_user,model_attendance_iot_user,base.group_user,1,1,1,1
\ No newline at end of file
diff --git a/attendance_iot/views/attendance_iot_manager_views.xml b/attendance_iot/views/attendance_iot_manager_views.xml
index 45004e72c..63bd93fc5 100644
--- a/attendance_iot/views/attendance_iot_manager_views.xml
+++ b/attendance_iot/views/attendance_iot_manager_views.xml
@@ -7,9 +7,8 @@
-
-
+
diff --git a/attendance_iot/views/attendance_iot_user_views.xml b/attendance_iot/views/attendance_iot_user_views.xml
new file mode 100644
index 000000000..a3a2c75d4
--- /dev/null
+++ b/attendance_iot/views/attendance_iot_user_views.xml
@@ -0,0 +1,16 @@
+
+
+
+ attendance.iot.user.tree
+ attendance.iot.user
+
+
+
+
+
+
+
+
+
+
+
diff --git a/attendance_iot/views/attendance_iot_views.xml b/attendance_iot/views/attendance_iot_views.xml
index 73f536e3f..8cd7beef2 100644
--- a/attendance_iot/views/attendance_iot_views.xml
+++ b/attendance_iot/views/attendance_iot_views.xml
@@ -9,6 +9,7 @@
+
diff --git a/attendance_iot/views/inherit_hr_employee_views.xml b/attendance_iot/views/inherit_hr_employee_views.xml
index 197b23551..7d280533e 100644
--- a/attendance_iot/views/inherit_hr_employee_views.xml
+++ b/attendance_iot/views/inherit_hr_employee_views.xml
@@ -8,10 +8,10 @@
-
+
-
+
diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml b/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml
index 2cb162faf..f4740ff43 100644
--- a/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml
+++ b/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml
@@ -11,8 +11,8 @@
@@ -21,7 +21,7 @@
@@ -29,7 +29,7 @@
diff --git a/yuthon_base/i18n/zh_CN.po b/yuthon_base/i18n/zh_CN.po
new file mode 100644
index 000000000..fe4b3966a
--- /dev/null
+++ b/yuthon_base/i18n/zh_CN.po
@@ -0,0 +1,10 @@
+#. module: base
+#. odoo-python
+#: code:addons/base/models/ir_rule.py:0
+#, python-format
+msgid ""
+"Uh-oh! Looks like you have stumbled upon some top-secret records.\n"
+"\n"
+"Sorry, %s doesn't have '%s' access to:"
+msgstr ""
+"对不起,%s没有'%s'来访问:"
\ No newline at end of file
diff --git a/yuthon_hr_attendance/controllers/applet_attendance.py b/yuthon_hr_attendance/controllers/applet_attendance.py
index 12aa67b06..0bff7e119 100644
--- a/yuthon_hr_attendance/controllers/applet_attendance.py
+++ b/yuthon_hr_attendance/controllers/applet_attendance.py
@@ -21,9 +21,14 @@ class AppletAttendance(Controller):
'user_id': 用户id
'check_in': [上班卡,正常]
'check_out': [下班卡,早退]
- 'state': 是否可以打卡
- 'state_result': 不可打卡原因
+ 'state': 是否可以打卡['yes', 'no']
+ 'state_result': 不可打卡原因 'xxx'
}
+ # 0.判断是否有用户,否则返回“此用户无权限”
+ # 1.根据经纬度判断是否可以打卡,如果不可以就直接返回“超出范围,不允许打卡”
+ # 2.把这个人的地址location,class,user_id,state-yes,state_result=''
+ # 2.check_in "YYYY-MM-DD HH:MM:SS" ['', ''] 如果没有传 ''
+ # 2.check_out "YYYY-MM-DD HH:MM:SS" ['', ''] 如果没有传 ''
"""
user_id = int(kw.get('id'))
user_id = request.env(user=SUPERUSER_ID)["res.user"].search([('wecom_id', '=', data.get('user_id'))])
@@ -60,7 +65,7 @@ class AppletAttendance(Controller):
小程序创建打卡记录
:return:
"""
- data = request.httprequest.json
+ user_id = int(kw.get('id'))
user_name = data.get('user_id')
employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('user_id', '=', user_name.id)])
if not employee_id:
diff --git a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py
index c1f14a773..8ee8ee671 100644
--- a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py
+++ b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py
@@ -40,6 +40,8 @@ class HrAttendanceDetail(models.Model):
employee_id = fields.Many2one('hr.employee', string="员工", readonly=True)
company_id = fields.Many2one('res.company', string="公司", related="employee_id.company_id", store=True)
department_id = fields.Many2one('hr.department', string="部门", related="employee_id.department_id", readonly=True, store=True)
+ source = fields.Selection([('iot', '考勤机'), ('mini_programs', '小程序')], string="来源")
+ attendance_iot_id = fields.Many2one('attendance.iot', string="设备号")
userid = fields.Char(string='userid')
groupname = fields.Char(string='打卡规则名称')
checkin_type = fields.Char(string='打卡类型')
diff --git a/yuthon_hr_attendance/views/hr_attendance_detail_wechat_views.xml b/yuthon_hr_attendance/views/hr_attendance_detail_wechat_views.xml
index 1fd684a5e..f9d5a49fc 100644
--- a/yuthon_hr_attendance/views/hr_attendance_detail_wechat_views.xml
+++ b/yuthon_hr_attendance/views/hr_attendance_detail_wechat_views.xml
@@ -37,8 +37,8 @@
-
-
+
+
diff --git a/yuthon_salary/models/inherit_hr_payslip_run.py b/yuthon_salary/models/inherit_hr_payslip_run.py
index 79ddcc61d..c1687ce8d 100644
--- a/yuthon_salary/models/inherit_hr_payslip_run.py
+++ b/yuthon_salary/models/inherit_hr_payslip_run.py
@@ -34,4 +34,14 @@ class InheritHrPayslipRun(models.Model):
rec.run_stage = 'issued'
+ def open_payslip(self):
+ return {
+ "name": "详情",
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'hr.payslip.run',
+ "view_mode": "form",
+ "res_id": self.id,
+ }
+
+
diff --git a/yuthon_salary/views/inherit_hr_payslip_run_views.xml b/yuthon_salary/views/inherit_hr_payslip_run_views.xml
index e11b6e1d8..0fa6a444b 100644
--- a/yuthon_salary/views/inherit_hr_payslip_run_views.xml
+++ b/yuthon_salary/views/inherit_hr_payslip_run_views.xml
@@ -16,6 +16,7 @@
+
diff --git a/yuthon_trade/models/yuthon_message_approval.py b/yuthon_trade/models/yuthon_message_approval.py
index eb6b0355d..f7360031e 100644
--- a/yuthon_trade/models/yuthon_message_approval.py
+++ b/yuthon_trade/models/yuthon_message_approval.py
@@ -12,7 +12,7 @@ class YuthonMessageApproval(models.Model):
code = fields.Char(string="编号",
default=lambda self: self.env['ir.sequence'].next_by_code('yuthon_leaving_approval_code'))
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
- department_id = fields.Many2one(related='users_id.employee_id.department_id', string="发布部门")
+ department_id = fields.Many2one(related='users_id.employee_id.department_id', string="发布部门", domain=[])
phone = fields.Char(related='users_id.employee_id.mobile_phone', string="联系方式")
documents_ids = fields.Many2many('ir.attachment', string="附件")
publish_ids = fields.Many2many('yuthon.publish.type', string="发布平台")
diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml
index 04a22c634..ef287d326 100644
--- a/yuthon_work_brand/views/hr_menus.xml
+++ b/yuthon_work_brand/views/hr_menus.xml
@@ -184,7 +184,7 @@
parent="hr_attendance_root_board_menu"
sequence="20"/>
@@ -194,7 +194,7 @@
action="attendance_iot.attendance_iot_datas_action"
sequence="10"/>