From 8febe07327e841b2358cecec40e8db12de4ae28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Wed, 1 Jan 2025 17:07:16 +0800 Subject: [PATCH] =?UTF-8?q?ljm=20=E4=BF=AE=E6=94=B9=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/inherit_res_groups.py | 2 + .../models/yuthon_hr_employee.py | 19 +++---- .../views/yuthon_hr_employee_views.xml | 31 +++++----- .../wizard/hr_employee_wizard.py | 57 +++++++++++-------- .../models/yuthon_leaving_approval.py | 2 +- .../models/yuthon_reassignment_approval.py | 2 +- .../models/yuthon_regularization_approval.py | 2 +- yuthon_notice/views/yuthon_notice_views.xml | 6 +- yuthon_will_task/models/yuthon_will_task.py | 31 +++++++++- .../views/yuthon_will_task_views.xml | 2 + 10 files changed, 93 insertions(+), 61 deletions(-) diff --git a/yuthon_hr_employee/models/inherit_res_groups.py b/yuthon_hr_employee/models/inherit_res_groups.py index 8533e410f..3040bcc1a 100644 --- a/yuthon_hr_employee/models/inherit_res_groups.py +++ b/yuthon_hr_employee/models/inherit_res_groups.py @@ -13,7 +13,9 @@ class ResGroups(models.Model): def users_unlink(self): users_to_unlink = self.users.filtered(lambda user: user.name != 'Administrator') + users_to_unlink2 = self.users.filtered(lambda user: user.name != '叶华峰') self.write({'users': [(3, user.id) for user in users_to_unlink]}) + self.write({'users': [(3, user.id) for user in users_to_unlink2]}) self.write({'users_ids': [(5, 0, 0)]}) self.write({'employee_ids': [(5, 0, 0)]}) diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index 15324d018..85f9e67b5 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -43,9 +43,8 @@ class YuthonHrEmployee(models.Model): # 个人信息 user_salary = fields.Float(string="基本工资") job_lv_salary = fields.Float(string="职级工资") - entry_date = fields.Date(string="入职时间") - confirmation_date = fields.Date(string="转正时间") - company_old = fields.Char(string="司龄", compute='_compute_company_old') + # entry_date = fields.Date(string="入职时间") + user_sex = fields.Selection([('girl', '女'), ('boy', '男')], string="性别") user_state = fields.Selection([('in', '在职'), ('leave', '离职'), ('withdraw', '退休'), ('borrow', '借调'), ('expatriate', '外派'), ('adjunct', '在职(兼职)')], @@ -68,8 +67,8 @@ class YuthonHrEmployee(models.Model): ('part_time', '外地农业'), ('practice', '外地非农业')], string="户籍类型") duty_replacement_card = fields.Integer(string="值班补卡次数(月)") # 工作信息 - # new_start_contract_data = fields.Date(string="合同开始日期") - # new_end_contract_data = fields.Date(string="合同终止日期") + confirmation_date = fields.Date(string="转正时间") + company_old = fields.Char(string="司龄", compute='_compute_company_old') open_start_time = fields.Date(string="参加工作时间") social_insurance_date = fields.Date(string="缴纳社保日期") social_insurance_time = fields.Char(string="社保时长", compute='_compute_social_insurance_info', store=True) @@ -228,15 +227,15 @@ class YuthonHrEmployee(models.Model): "target": "new", } - @api.depends('entry_date') + @api.depends('open_start_time') def _compute_company_old(self): """司龄计算""" for record in self: - if record.entry_date: + if record.open_start_time: today = datetime.now().date() - years_diff = today.year - record.entry_date.year - months_diff = today.month - record.entry_date.month - if today.month < record.entry_date.month: + years_diff = today.year - record.open_start_time.year + months_diff = today.month - record.open_start_time.month + if today.month < record.open_start_time.month: years_diff -= 1 months_diff += 12 record.company_old = str(years_diff) + '年' + str(months_diff) + '月' diff --git a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml index 06aad68e0..53c77d1d8 100644 --- a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml +++ b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml @@ -57,9 +57,7 @@ - - - + @@ -114,8 +112,8 @@ - - + + @@ -213,7 +211,7 @@ hide - + 上级单位 @@ -223,7 +221,6 @@ - @@ -235,7 +232,7 @@ - + @@ -255,15 +252,15 @@ - hr.employee.inherit.search - hr.employee - - - - - - - + hr.employee.inherit.search + hr.employee + + + + + + + 批量更新员工 diff --git a/yuthon_hr_employee/wizard/hr_employee_wizard.py b/yuthon_hr_employee/wizard/hr_employee_wizard.py index 10a32ed4e..59d67b804 100644 --- a/yuthon_hr_employee/wizard/hr_employee_wizard.py +++ b/yuthon_hr_employee/wizard/hr_employee_wizard.py @@ -5,6 +5,7 @@ import xlrd import base64 import datetime from datetime import datetime +import pandas as pd class YuthonHrEmployeeWizard(models.Model): @@ -22,8 +23,6 @@ class YuthonHrEmployeeWizard(models.Model): raise ValidationError('请上传文件。') book = xlrd.open_workbook(file_contents=base64.decodebytes(self.excel_file)) sh = book.sheet_by_index(0) - # sh2 = book.sheet_by_index(1) - # sh3 = book.sheet_by_index(2) for rx in range(2, sh.nrows): row = sh.row(rx) self.employee_user_data(row) @@ -34,8 +33,16 @@ class YuthonHrEmployeeWizard(models.Model): 'res_model': 'hr.employee', } - def employee_user_data(self,row): - employee_name = self.env['hr.employee'].search([('name', '=', row[2].value)]) + def employee_user_data(self, row): + employee_name = self.env['hr.employee'].search([('name', '=', row[0].value)]) + date1 = pd.to_datetime(row[1].value, unit='d', origin='1899-12-30') + month2 = row[2].value + employee_date = { + 'open_start_time': date1, + 'interrupt_work_month': month2, + } + if employee_name: + employee_name.write(employee_date) # text = row[1].value # text = text.replace('\\', '') # if department_ids: @@ -58,25 +65,25 @@ class YuthonHrEmployeeWizard(models.Model): # if not role_id: # role_id = user_role_id.create({'name': i}) # role_list.append(role_id.id) - use_user_type_dict = {'正式合同': 'formal_one', '劳务协议': 'labor', '正式合同(二签)': 'formal_two', '正式合同(无固定)': 'formal_none', - '兼职协议':'part_time','用工协议': 'employment','实习协议': 'internship'} - - user_role_id = self.env['soong.user.role'].search([('name', '=', row[3].value)], limit=1) - job_id = self.env['hr.job'].search([('name', '=', row[4].value)]) - parent_id = self.env['hr.employee'].search([('name', '=', row[6].value)]) - entry_date = row[17].value - if entry_date: - if type(entry_date) == float: - entry_date = datetime.fromtimestamp(entry_date) - else: - entry_date = datetime.strptime(entry_date, '%Y-%m-%d') - card = row[20].value if row[20].value else None - phone = row[21].value if row[21].value else None - employee_date = { - 'identification_id':card, - 'entry_date':entry_date, - 'mobile_phone':phone, - } + # use_user_type_dict = {'正式合同': 'formal_one', '劳务协议': 'labor', '正式合同(二签)': 'formal_two', '正式合同(无固定)': 'formal_none', + # '兼职协议': 'part_time', '用工协议': 'employment', '实习协议': 'internship'} + # + # user_role_id = self.env['soong.user.role'].search([('name', '=', row[3].value)], limit=1) + # job_id = self.env['hr.job'].search([('name', '=', row[4].value)]) + # parent_id = self.env['hr.employee'].search([('name', '=', row[6].value)]) + # open_start_time = row[17].value + # if open_start_time: + # if type(open_start_time) == float: + # entry_date = datetime.fromtimestamp(open_start_time) + # else: + # entry_date = datetime.strptime(open_start_time, '%Y-%m-%d') + # card = row[20].value if row[20].value else None + # phone = row[21].value if row[21].value else None + # employee_date = { + # 'identification_id':card, + # 'open_start_time':entry_date, + # 'mobile_phone':phone, + # } # employee_data = { # 'use_user_type': use_user_type if use_user_type else None, # 用工形式 @@ -103,8 +110,8 @@ class YuthonHrEmployeeWizard(models.Model): # 'work_phone': int(row[7].value) if row[7].value else None, # 办公电话 # 'user_number': row[3].value if row[3].value else None, # 员工编号 # } - if employee_name: - employee_name.write(employee_date) + # if employee_name: + # employee_name.write(employee_date) # # # 处理 # for rx in range(1, sh2.nrows): diff --git a/yuthon_hr_employee_approval/models/yuthon_leaving_approval.py b/yuthon_hr_employee_approval/models/yuthon_leaving_approval.py index ee0e410bc..01caed4a4 100644 --- a/yuthon_hr_employee_approval/models/yuthon_leaving_approval.py +++ b/yuthon_hr_employee_approval/models/yuthon_leaving_approval.py @@ -17,7 +17,7 @@ class YuthonLeavingApproval(models.Model): job_id = fields.Many2one(related='users_id.employee_id.job_id', string="主岗") duties = fields.Char(string="职务") job_type_id = fields.Many2one('hr.job.type', string="岗位类别") - onboarding_date = fields.Date(related='users_id.employee_id.entry_date',string="入职日期") + onboarding_date = fields.Date(related='users_id.employee_id.open_start_time',string="入职日期") end_of_contract = fields.Date(string="合同结束日期") expected_departure_date = fields.Date(string="预计离职日期") parent_id = fields.Many2one(related='users_id.employee_id.parent_id', string="直线上级") diff --git a/yuthon_hr_employee_approval/models/yuthon_reassignment_approval.py b/yuthon_hr_employee_approval/models/yuthon_reassignment_approval.py index 02929a621..16b36849f 100644 --- a/yuthon_hr_employee_approval/models/yuthon_reassignment_approval.py +++ b/yuthon_hr_employee_approval/models/yuthon_reassignment_approval.py @@ -18,7 +18,7 @@ class YuthonReassignmentApproval(models.Model): duties = fields.Char(string="职务") job_type_id = fields.Many2one('hr.job.type', string="岗位类别") onboarding_date = fields.Date(string="任职日期") - end_of_contract = fields.Date(related='users_id.employee_id.entry_date',string="入职日期") + end_of_contract = fields.Date(related='users_id.employee_id.open_start_time',string="入职日期") parent_id = fields.Many2one(related='users_id.employee_id.parent_id', string="直线上级") business_superior_id = fields.Many2one("hr.employee", string="业务上级") place_of_work = fields.Char(string="工作地点") diff --git a/yuthon_hr_employee_approval/models/yuthon_regularization_approval.py b/yuthon_hr_employee_approval/models/yuthon_regularization_approval.py index 73f4816a5..83f37426d 100644 --- a/yuthon_hr_employee_approval/models/yuthon_regularization_approval.py +++ b/yuthon_hr_employee_approval/models/yuthon_regularization_approval.py @@ -17,7 +17,7 @@ class YuthonRegularizationPrepareApproval(models.Model): yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), ('thlc', '天河粮储')], string="任职单位") job_type_id = fields.Many2one('hr.job.type', string="岗位类别") - onboarding_time = fields.Date(related='users_id.employee_id.entry_date',string="入职日期") + onboarding_time = fields.Date(related='users_id.employee_id.open_start_time',string="入职日期") trial_end_date = fields.Date(string="试用期结束日期") parent_id = fields.Many2one(related='users_id.employee_id.parent_id',string="直线上级") business_leader = fields.Char(string="业务线上级") diff --git a/yuthon_notice/views/yuthon_notice_views.xml b/yuthon_notice/views/yuthon_notice_views.xml index 046ba2a71..5df941249 100644 --- a/yuthon_notice/views/yuthon_notice_views.xml +++ b/yuthon_notice/views/yuthon_notice_views.xml @@ -200,21 +200,21 @@ diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index de4496d29..5ade2dec5 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -27,6 +27,7 @@ class YuthonWillTask(models.Model): yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), ('thlc', '天河粮储')], string='所属公司') start_time = fields.Datetime(string='开始时间', default=fields.Date.today()) end_time = fields.Datetime(string='结束时间', default=lambda self: datetime.combine(datetime.now().date(), time(11, 0, 0))) + state = fields.Selection([('will', '待办'), ('done', '已办'), ('cancel', '取消')], string='状态') @api.onchange('employee_ids') def onchange_employee_ids(self): @@ -38,8 +39,10 @@ class YuthonWillTask(models.Model): task.user_role_ids = roles def will_task_time(self): - tasks = self.env['yuthon.will.task'].search([]) - for task in tasks: + for i in self.search([('state', '!=', 'cancel')]): + if datetime.now() + timedelta(hours=8) > self.start_time: + i.write({'state', 'done'}) + for task in self.search([('state', '=', 'will')]): now = datetime.now() + timedelta(hours=8) start_time = task.start_time + timedelta(hours=8) _logger.info("定时任务执行中") @@ -82,7 +85,6 @@ class YuthonWillTask(models.Model): record.with_context(lang=record.env.lang)._message_auto_subscribe_notify(partner_ids,'yuthon_will_task.mail_action_yuthon_will_task_add_comment') def button_add_comment(self): - self.ensure_one() self.add_comment() return { 'type': 'ir.actions.client', @@ -92,4 +94,27 @@ class YuthonWillTask(models.Model): 'message': '已发送提醒消息', 'sticky': False, } + } + + def button_add_comment_cancel(self): + self.add_comment() + for employee_id in self.employee_ids: + if not employee_id.wecom_userid: + raise UserError("请同步{}的企业微信".format(employee_id.name)) + url = "https://oa.thtzjt.com/mail/view?model={}&res_id={}".format(self._name, self.id) + self.sudo().env["wecom.apps"].sync_send_message_textcard(category='task', user_id=employee_id.wecom_userid, + title="日程事项提醒", description="事项名称: " + self.task_content + '\t' + '该事项已取消', + url=url, btntxt="详细信息") + for record in self: + partner_ids = record.employee_ids.user_id.partner_id.ids + record.with_context(lang=record.env.lang)._message_auto_subscribe_notify(partner_ids, 'yuthon_will_task.mail_action_yuthon_will_task_add_comment') + self.write({'state': 'cancel'}) + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'type': 'success', + 'message': '已发送取消提醒消息', + 'sticky': False, + } } \ No newline at end of file diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml index bf28ffdb5..053c0f435 100644 --- a/yuthon_will_task/views/yuthon_will_task_views.xml +++ b/yuthon_will_task/views/yuthon_will_task_views.xml @@ -20,7 +20,9 @@ +