From 4f0fb1287ffbc8e75ae707dfcebc0dfbc453d540 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Wed, 4 Jun 2025 20:34:26 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
attendance_iot/__manifest__.py | 1 +
attendance_iot/controllers/kaoqin_test.py | 22 +++++++++++++---
attendance_iot/models/__init__.py | 1 +
attendance_iot/models/attendance_iot.py | 2 ++
.../models/attendance_iot_manager.py | 25 +++++++++++++++----
attendance_iot/models/attendance_iot_user.py | 13 ++++++++++
attendance_iot/models/hr_employee.py | 2 +-
attendance_iot/security/ir.model.access.csv | 3 ++-
.../views/attendance_iot_manager_views.xml | 3 +--
.../views/attendance_iot_user_views.xml | 16 ++++++++++++
attendance_iot/views/attendance_iot_views.xml | 1 +
.../views/inherit_hr_employee_views.xml | 4 +--
.../soong_workflow_comment_wizard_view.xml | 8 +++---
yuthon_base/i18n/zh_CN.po | 10 ++++++++
.../models/yuthon_message_approval.py | 2 +-
yuthon_work_brand/views/hr_menus.xml | 4 +--
16 files changed, 96 insertions(+), 21 deletions(-)
create mode 100644 attendance_iot/models/attendance_iot_user.py
create mode 100644 attendance_iot/views/attendance_iot_user_views.xml
create mode 100644 yuthon_base/i18n/zh_CN.po
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..0d3cde185 100644
--- a/attendance_iot/controllers/kaoqin_test.py
+++ b/attendance_iot/controllers/kaoqin_test.py
@@ -1,3 +1,5 @@
+from venv import create
+
from odoo.http import Controller, request, route
from datetime import datetime
from odoo import models, fields, api, http, SUPERUSER_ID, _
@@ -28,9 +30,23 @@ class BusController(Controller):
@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)
+ name = request.jsonrequest.get('sn') #设备序列号
+ attendance_iot_id = self.env["attendance.iot"].search([('name', '=', name)])
+ # 创建设备
+ if not attendance_iot_id:
+ self.env["attendance.iot"].create({
+ 'name': name,
+ })
+ user_id = request.jsonrequest.get('content')[0]['user_id'] #用户id
+ employee = self.env["hr.employee"].search([('user_id', '=', user_id)])
+ # 判断员工是否绑定多台设备
+ if employee and attendance_iot_id not in employee.attendance_iot_ids.mapped('attendance_iot_id'):
+ employee.write({
+ 'attendance_iot_ids': [(0, 0, {
+ 'employee_id': employee.id,
+ 'attendance_iot_id': attendance_iot_id.id
+ })]
+ })
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_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"/>