添加功能
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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": "更新成功"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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="设备有效期")
|
||||
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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="有效日期")
|
||||
@@ -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="考勤机信息")
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
@@ -7,9 +7,8 @@
|
||||
<tree string="考勤机设备管理" editable="bottom">
|
||||
<field name="attendance_iot_id"/>
|
||||
<field name="attendance_address"/>
|
||||
<field name="employee_id" required="1"/>
|
||||
<field name="id_valid" required="1"/>
|
||||
<field name="data_selection" required="1"/>
|
||||
<button name="employee_message" string="员工数据" type="object" class="oe_highlight"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="attendance_iot_user_tree" model="ir.ui.view">
|
||||
<field name="name">attendance.iot.user.tree</field>
|
||||
<field name="model">attendance.iot.user</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom">
|
||||
<field name="attendance_iot_id"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="company_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<field name="attendance_address"/>
|
||||
<field name="broker"/>
|
||||
<field name="port"/>
|
||||
<field name="id_valid"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
<xpath expr="//page[@name='hr_settings']" position="after">
|
||||
<page string="考勤机信息">
|
||||
<field name="attendance_iot_ids">
|
||||
<tree>
|
||||
<tree editable="bottom">
|
||||
<field name="attendance_iot_id"/>
|
||||
<field name="attendance_address"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="employee_id" column_invisible="1"/>
|
||||
<field name="id_valid"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
<group invisible="node_btn_name in ['分发', '结束', '收回']">
|
||||
<div class="oe_comment_block" style=" width:1200%; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin-bottom: 16px;">
|
||||
<label for="comment_note_id" string="常用意见" domain="[('note_setting_id.users_role_ids', 'in', user_role_id)]"
|
||||
style="font-weight: bold; margin-bottom: 8px; display: block;" options="{'no_create': True}"/>
|
||||
<field name="comment_note_id" class="mb-3" style="width: 100%;"/>
|
||||
style="font-weight: bold; margin-bottom: 8px; display: block;"/>
|
||||
<field name="comment_note_id" class="mb-3" style="width: 100%;" options="{'no_create': True}"/>
|
||||
<field name="comment_note" placeholder="请输入意见内容..." style="width: 100%;"/>
|
||||
</div>
|
||||
</group>
|
||||
@@ -21,7 +21,7 @@
|
||||
<div class="oe_comment_block" style=" width:1200%; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin-bottom: 16px;">
|
||||
<label for="comment_note_id" string="结束意见" domain="[('note_setting_id.users_role_ids', 'in', user_role_id)]"
|
||||
style="font-weight: bold; margin-bottom: 8px; display: block;"/>
|
||||
<field name="comment_note_id" class="mb-3" style="width: 100%;"/>
|
||||
<field name="comment_note_id" class="mb-3" style="width: 100%;" options="{'no_create': True}"/>
|
||||
<field name="comment_note" placeholder="请输入意见内容..." style="width: 100%;"/>
|
||||
</div>
|
||||
</group>
|
||||
@@ -29,7 +29,7 @@
|
||||
<div class="oe_comment_block" style=" width:1200%; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin-bottom: 16px;">
|
||||
<label for="comment_note_id" string="分发意见" domain="[('note_setting_id.users_role_ids', 'in', user_role_id)]"
|
||||
style="font-weight: bold; margin-bottom: 8px; display: block;"/>
|
||||
<field name="comment_note_id" class="mb-3" style="width: 100%;"/>
|
||||
<field name="comment_note_id" class="mb-3" style="width: 100%;" options="{'no_create': True}"/>
|
||||
<field name="comment_note" placeholder="请输入意见内容..." style="width: 100%;"/>
|
||||
</div>
|
||||
</group>
|
||||
|
||||
@@ -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'来访问:"
|
||||
@@ -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="发布平台")
|
||||
|
||||
@@ -184,7 +184,7 @@
|
||||
parent="hr_attendance_root_board_menu"
|
||||
sequence="20"/>
|
||||
<menuitem id="menu_attendance_iot_manager"
|
||||
name="考勤机设备"
|
||||
name="员工管理"
|
||||
parent="time_attendance_machine_management"
|
||||
action="attendance_iot.attendance_iot_manager_action"
|
||||
sequence="1"/>
|
||||
@@ -194,7 +194,7 @@
|
||||
action="attendance_iot.attendance_iot_datas_action"
|
||||
sequence="10"/>
|
||||
<menuitem id="menu_attendance_iot"
|
||||
name="考勤机设备"
|
||||
name="设备管理"
|
||||
parent="time_attendance_machine_management"
|
||||
action="attendance_iot.attendance_iot_action"
|
||||
sequence="21"/>
|
||||
|
||||
Reference in New Issue
Block a user