diff --git a/oo_list_manager/static/src/views/list/list_controller.js b/oo_list_manager/static/src/views/list/list_controller.js index 53f1b4429..ebd1ffd53 100644 --- a/oo_list_manager/static/src/views/list/list_controller.js +++ b/oo_list_manager/static/src/views/list/list_controller.js @@ -33,7 +33,7 @@ patch(ListController.prototype, { onWillStart(async () => { const manager_data = await this.orm.call('ir.ui.view', 'get_manager_data', [this.env.config.viewId]); - if (!Object.keys(manager_data).length) { + if (!Object.keys(manager_data).length || !manager_data.columns) { this.ooManager.columns.forEach(val => { val.visibility = !!!val.column_invisible; }) @@ -41,6 +41,7 @@ patch(ListController.prototype, { Object.assign(this.ooManager, manager_data); this.archInfo.advanced_filter = this.ooManager.filter; } + this.ooManager.show = manager_data.show; }) usePosition('ooListRef', () => this.ooManagerRef.el, { diff --git a/yuthon_hr_attendance/__manifest__.py b/yuthon_hr_attendance/__manifest__.py index 17b80c545..dabd24209 100644 --- a/yuthon_hr_attendance/__manifest__.py +++ b/yuthon_hr_attendance/__manifest__.py @@ -59,7 +59,6 @@ 'wizard/attendance_correct_wizard.xml', 'wizard/yuthon_run_wizard.xml', 'views/applet_address_views.xml', - 'views/applet_security_views.xml', 'views/all_attendance_menu.xml', ], 'assets': { diff --git a/yuthon_hr_attendance/controllers/applet_address.py b/yuthon_hr_attendance/controllers/applet_address.py index 026811770..c5bcd0da7 100644 --- a/yuthon_hr_attendance/controllers/applet_address.py +++ b/yuthon_hr_attendance/controllers/applet_address.py @@ -1,5 +1,6 @@ from odoo import models, fields, api, http, SUPERUSER_ID, _ import logging +from odoo.exceptions import UserError _logger = logging.getLogger(__name__) @@ -29,14 +30,34 @@ class AppletSecurity(models.Model): _name = 'applet.security' _description = "小程序权限管理" - employee_id = fields.Char(string="员工") - attendance_card = fields.Boolean(string="出勤打卡") - hydropower = fields.Boolean(string="水电抄表") - main_menu = fields.Selection([('att', '打卡'), ('hydropower', '水电')], string="首页") + employee_id = fields.Many2one('hr.employee', string="员工") + company_id = fields.Many2one(related="employee_id.company_id", string="公司") + department_id = fields.Many2one(related="employee_id.department_id", string="部门") + applet_security_setting_ids = fields.Many2many('applet.security.setting', string="权限板块") def init_applet_security(self): """ 初始化权限 :return: """ - pass \ No newline at end of file + employees = self.env['hr.employee'].search([]) + existing_records = self.search([]) + existing_employee_ids = existing_records.mapped('employee_id.id') + clock_in_setting = self.env['applet.security.setting'].search([('name', '=', '打卡')], limit=1) + if not clock_in_setting: + raise UserError('请添加打卡板块') + for employee in employees: + if employee.id in existing_employee_ids: + existing_records.filtered(lambda r: r.employee_id.id == employee.id) + else: + self.create({ + 'employee_id': employee.id, + # 'applet_security_setting_ids': [(6, 0, [])] + 'applet_security_setting_ids': [(4, clock_in_setting.id)], + }) + + +class AppletSecuritySeeting(models.Model): + _name = 'applet.security.setting' + + name = fields.Char(string="板块名称") \ 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 73e34b4e2..f290fbe30 100644 --- a/yuthon_hr_attendance/controllers/applet_attendance.py +++ b/yuthon_hr_attendance/controllers/applet_attendance.py @@ -48,8 +48,8 @@ class AppletAttendance(Controller): user_id = request.env(user=SUPERUSER_ID)["res.users"].search([('id', '=', int(kw['user_id']))]) employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_id.name)]) 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 + timedelta(hours=8) - check_out = attendance_id.check_out + timedelta(hours=8) + check_in = attendance_id.check_in + timedelta(hours=8) if attendance_id.check_in else '' + check_out = attendance_id.check_out + timedelta(hours=8) if attendance_id.check_out else '' check_in_start = attendance_id.shift_id.template_id.check_in_start check_out_end = attendance_id.shift_id.template_id.check_out_end start_minute = int((check_in_start - int(check_in_start)) * 60) @@ -204,7 +204,7 @@ class AppletAttendance(Controller): # 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()) + # holiday_data = self.get_holiday_data(current_month_first.date(), current_month_last.date()) # 本月考勤记录 leave_days = 0 current_attendance = request.env(user=SUPERUSER_ID)['hr.attendance'].sudo().search([ @@ -219,7 +219,7 @@ class AppletAttendance(Controller): ('date_from', '>=', current_month_first), ('date_to', '<=', current_month_last), ('state', 'in', ['confirm', 'validate1']) - ]) + ]) for leave in leave_ids: leave_days += leave.number_of_days, @@ -238,7 +238,8 @@ class AppletAttendance(Controller): 'message': 'OK', 'data': { 'current_month': { - 'holiday_data': holiday_data, + # 'holiday_data': holiday_data, + 'holiday_data': {"holiday_list": [], "shift_days_list": []}, 'banner_rote': current_stats, 'attendance_data': current_records, }, @@ -270,8 +271,10 @@ class AppletAttendance(Controller): check_out_status = '缺卡' if not check_out else ('早退' if is_early_card else '正常') check_in_str = (check_in + timedelta(hours=8)).strftime('%H:%M:%S') if check_in else '缺卡' check_out_str = (check_out + timedelta(hours=8)).strftime('%H:%M:%S') if check_out else '缺卡' - check_in_html = f'
{check_in_status}
' if check_in_status in ['迟到', '早退', '缺卡'] else f'{check_in_status}
' - check_out_html = f'{check_out_status}
' if check_out_status in ['迟到', '早退','缺卡'] else f'{check_out_status}
' + check_in_html = f'{check_in_status}
' if check_in_status in ['迟到', '早退', + '缺卡'] else f'{check_in_status}
' + check_out_html = f'{check_out_status}
' if check_out_status in ['迟到', '早退', + '缺卡'] else f'{check_out_status}
' # 添加到记录列表 records.append({ 'date': att.current_data.strftime('%Y-%m-%d'), @@ -301,7 +304,7 @@ class AppletAttendance(Controller): # 将date对象转换为datetime对象 start_datetime = datetime.combine(start_date, datetime.min.time()) end_datetime = datetime.combine(end_date, datetime.max.time()) - domain.extend([("date_from", "<=", end_datetime),("date_to", ">=", start_datetime)]) + domain.extend([("date_from", "<=", end_datetime), ("date_to", ">=", start_datetime)]) calendar_leaves = request.env(user=SUPERUSER_ID)['resource.calendar.leaves'].search(domain) # 根据name 来进行去重 unique_leaves = {} diff --git a/yuthon_hr_attendance/security/ir.model.access.csv b/yuthon_hr_attendance/security/ir.model.access.csv index f92eca4e4..f65d0f6f2 100644 --- a/yuthon_hr_attendance/security/ir.model.access.csv +++ b/yuthon_hr_attendance/security/ir.model.access.csv @@ -58,3 +58,4 @@ access_yuthon_integrated_wizard,yuthon.integrated.wizard,model_yuthon_integrated access_applet_address,applet.address,model_applet_address,base.group_user,1,1,1,1 access_applet_security,applet.security,model_applet_security,base.group_user,1,1,1,1 +access_applet_security_setting,applet.security.setting,model_applet_security_setting,base.group_user,1,1,1,1 diff --git a/yuthon_hr_attendance/views/applet_address_views.xml b/yuthon_hr_attendance/views/applet_address_views.xml index a5c2dcbf5..31e7f9e87 100644 --- a/yuthon_hr_attendance/views/applet_address_views.xml +++ b/yuthon_hr_attendance/views/applet_address_views.xml @@ -14,17 +14,49 @@ -