From 3ba6026948382c8fe58de13faab589fa37fd8eaa Mon Sep 17 00:00:00 2001 From: pengyuthon Date: Fri, 16 Jan 2026 00:02:06 +0800 Subject: [PATCH] 1 --- .../wizard/soong_workflow_comment_wizard.py | 18 +++---- yuthon_hr_attendance/controllers/portal.py | 52 +++++++------------ yuthon_salary/controllers/salary_phone.py | 7 +-- yuthon_wechat/models/wecom_apps.py | 3 -- 4 files changed, 29 insertions(+), 51 deletions(-) diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard.py b/soong_workflow/wizard/soong_workflow_comment_wizard.py index 831ab90ae..4be0df38a 100644 --- a/soong_workflow/wizard/soong_workflow_comment_wizard.py +++ b/soong_workflow/wizard/soong_workflow_comment_wizard.py @@ -453,12 +453,10 @@ class SoongWorkflowCommentWizard(models.TransientModel): url = self.sudo().env["wecom.apps"].generate_oauth_login_url(target_url, category='oa') _logger.info(f"===================当前的url为{url}=============================") result_data = self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', - user_id='78', + user_id=employee.wecom_userid, title= record_id._description if 'Purchase Order' != record_id._description else '采购订单', - description="标题: {}\n".format( - record_id.name) + self.env.user.name + ' ' + str( - fields.Datetime.now() + timedelta( - hours=8)), + description="标题: {}\n".format(record_id.name) + self.env.user.name + ' ' + str( + fields.Datetime.now() + timedelta(hours=8)), url=url, btntxt="查看详情") msg_id = result_data[-1]['msgid'] target_logs = next_node_log_records.filtered(lambda l: l.done_by.id == employee.user_id.id) @@ -689,13 +687,13 @@ class SoongWorkflowCommentWizard(models.TransientModel): url = self.sudo().env["wecom.apps"].generate_oauth_login_url(target_url, category='oa') if self.res_model == 'purchase.order': self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', - user_id='78', + user_id=employee.wecom_userid, title='采购审批单', description=f"{record_id.name}审批结束,可采购入库", url=url, btntxt="查看详情") else: self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', - user_id='78', + user_id=employee.wecom_userid, title=record_id._description, description=f"标题为{record_id.name}的{record_id._description}已结束,请归档", url=url, btntxt="查看详情") @@ -721,7 +719,7 @@ class SoongWorkflowCommentWizard(models.TransientModel): "done_by": self.employee_ids.user_id.id, "node_btn_name": "0", }) - result_data = self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id='78', title=record_id._description, description=description, url=url, btntxt="查看详情") + result_data = self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id=self.employee_ids.wecom_userid, title=record_id._description, description=description, url=url, btntxt="查看详情") msg_id = result_data[-1]['msgid'] log_id.msg_id = msg_id for emp in self.dep_manager_employee_ids: @@ -736,7 +734,7 @@ class SoongWorkflowCommentWizard(models.TransientModel): "done_by": emp.user_id.id, "node_btn_name": "4", }) - result_data = self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id='78', title=record_id._description + "承办", description=description, url=url, btntxt="查看详情") + result_data = self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id=emp.wecom_id, title=record_id._description + "承办", description=description, url=url, btntxt="查看详情") msg_id = result_data[-1]['msgid'] log_id.msg_id = msg_id for employee in self.circulated_employee_ids: @@ -769,7 +767,7 @@ class SoongWorkflowCommentWizard(models.TransientModel): "node_btn_id": self.node_btn_id.id, "approval_state": "0", }) - result_data = self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id='78', title=record_id._description + "传阅/抄送",description=description, url=url, btntxt="查看详情") + result_data = self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id=employee.wecom_userid, title=record_id._description + "传阅/抄送",description=description, url=url, btntxt="查看详情") msg_id = result_data[-1]['msgid'] log2_id.msg_id = msg_id workflow_record_id.employee_ids = self.dep_manager_employee_ids + self.employee_ids + self.circulated_employee_ids diff --git a/yuthon_hr_attendance/controllers/portal.py b/yuthon_hr_attendance/controllers/portal.py index 35e83e741..dfd5bb735 100644 --- a/yuthon_hr_attendance/controllers/portal.py +++ b/yuthon_hr_attendance/controllers/portal.py @@ -52,49 +52,35 @@ class CustomerPortal(portal.CustomerPortal): @http.route('/phone/vacation/self', type='http', auth="none", csrf=False, cors='*') def phone_vacation_self(self, **kw): - users_id = int(kw.get('users_id')) - user = request.env['res.users'].sudo().browse(int(users_id)) - employee_id = user.with_company(user.company_id.id).employee_id.id - records = request.env['yuthon.vacation.reports'].sudo().search( - [('employee_id', '=', employee_id)]) + records = request.env['yuthon.vacation.reports'].sudo().search([('employee_id.id', '=', kw.get('employee_id'))]) data = {} for record in records: year = record.vacation_date.year - month = record.vacation_date.month - data[year] = year - data[month] = month + key = f'{year}年' + if key not in data: + data[key] = [] + vacation_state = '已确认' if record.vacation_state == 'confirmed' else '待确认' + data[key].append({ + 'id': record.id, + 'state': vacation_state, + 'month': record.vacation_date.month, + }) return json.dumps({'data': data, 'code': 200, 'message': ''}) @http.route('/phone/vacation/self/detail', type='http', auth="none", csrf=False, cors='*') def phone_vacation_self_detail(self, **kw): - users_id = int(kw.get('users_id')) - user = request.env['res.users'].sudo().browse(int(users_id)) - employee_id = user.with_company(user.company_id.id).employee_id.id - year = int(kw.get('year')) - month = int(kw.get('month')) - records = request.env['yuthon.vacation.reports'].sudo().search( - [('employee_id', '=', employee_id)]) - detail = {} - for record in records: - tar_year = record.date_from.year - tar_month = record.date_from.month - if tar_year == year and tar_month == month: - detail = record.read([]) + records = request.env['yuthon.vacation.reports'].sudo().search([('id', '=', kw.get('id'))]) data = { - 'year': year, - 'month': month, - 'detail': detail + '日期': records.display_date, + '剩余年假': records.leave, + '剩余补休': records.working_overtime, + '剩余误餐费': records.meal_fee, + '剩余体检费': records.medical_fee, } return json.dumps({'data': data, 'code': 200, 'message': ''}) @http.route('/phone/vacation/self/status', type='http', auth="none", csrf=False, cors='*') def phone_vacation_self_status(self, **kw): - record_id = int(kw.get('record_id')) - state = kw.get('state') - record = request.env['yuthon.vacation.reports'].sudo().browse(record_id) - if state == 'done': - record.vacation_state = 'confirmed' - data = 'success' - else: - data = '' - return json.dumps({'data': data, 'code': 200, 'message': ''}) + record_id = request.env['yuthon.vacation.reports'].sudo().search([('id', '=', kw.get('id'))]) + record_id.write({'vacation_state': 'confirmed'}) + return json.dumps({'code': 200, 'message': 'OK'}) diff --git a/yuthon_salary/controllers/salary_phone.py b/yuthon_salary/controllers/salary_phone.py index 46f8bd30c..226e1be6a 100644 --- a/yuthon_salary/controllers/salary_phone.py +++ b/yuthon_salary/controllers/salary_phone.py @@ -66,8 +66,7 @@ class YuthonWillTask(http.Controller): users_id = int(kw.get('users_id')) user = request.env['res.users'].sudo().browse(int(users_id)) employee_id = user.with_company(user.company_id.id).employee_id.id - records = request.env['hr.payslip'].sudo().search( - [('employee_id', '=', employee_id)]) + records = request.env['hr.payslip'].sudo().search([('employee_id', '=', employee_id)]) data = {} for record in records: year = record.date_from.year @@ -75,9 +74,7 @@ class YuthonWillTask(http.Controller): if year not in data.keys(): data[year] = {'total': 0} if month not in data[year].keys(): - data[year][month] = { - 'total': record.actual_salary - } + data[year][month] = {'total': record.actual_salary} data[year]['total'] += record.actual_salary return json.dumps({'data': data, 'code': 200, 'message': ''}) diff --git a/yuthon_wechat/models/wecom_apps.py b/yuthon_wechat/models/wecom_apps.py index 85f804157..40953572d 100644 --- a/yuthon_wechat/models/wecom_apps.py +++ b/yuthon_wechat/models/wecom_apps.py @@ -354,17 +354,14 @@ class WeComApps(models.Model): OAuth登录链接URL """ base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') - # 如果target_url不是完整URL,补全为完整URL if not target_url.startswith('http'): if target_url.startswith('/'): target_url = f"{base_url}{target_url}" else: target_url = f"{base_url}/{target_url}" - # 编码目标URL作为state参数 encoded_target_url = quote(target_url, safe='') - # 编码回调URI redirect_uri = quote(f'{base_url}/wechat/login_by_code', safe='')