From f6d159896a802f16fd9c1cb617877a1e5165fe87 Mon Sep 17 00:00:00 2001 From: pengyuthon Date: Sun, 25 Jan 2026 22:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E5=8B=A4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_hr_attendance/controllers/portal.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/yuthon_hr_attendance/controllers/portal.py b/yuthon_hr_attendance/controllers/portal.py index d0da77bc4..5e11248db 100644 --- a/yuthon_hr_attendance/controllers/portal.py +++ b/yuthon_hr_attendance/controllers/portal.py @@ -4,6 +4,7 @@ from odoo import fields, http, SUPERUSER_ID, _ from odoo.exceptions import AccessError, MissingError, ValidationError from odoo.http import request from ....addons.portal.controllers import portal +from datetime import datetime, date, time, timedelta class CustomerPortal(portal.CustomerPortal): @@ -69,9 +70,21 @@ class CustomerPortal(portal.CustomerPortal): @http.route('/phone/vacation/self/detail', type='http', auth="none", csrf=False, cors='*') def phone_vacation_self_detail(self, **kw): - records = request.env['yuthon.vacation.reports'].sudo().search([('id', '=', kw.get('id'))]) + record = request.env['yuthon.vacation.reports'].sudo().search([('id', '=', kw.get('id'))]) + current_date = record.vacation_date + if current_date.month == 1: + last_month_year = current_date.year - 1 + last_month = 12 + else: + last_month_year = current_date.year + last_month = current_date.month - 1 + records = request.env['yuthon.vacation.reports'].sudo().search([ + ('employee_id', '=', record.employee_id.id), + ('vacation_date', '>=', f'{last_month_year}-{last_month:02d}-01'), + ('vacation_date', '<', f'{last_month_year}-{last_month + 1:02d}-01' if last_month < 12 else f'{last_month_year + 1}-01-01') + ], limit=1) data = { - '日期': records.display_date, + '日期': record.display_date, '应到': records.should_attendance, '实到': records.actual_attendance, '迟到': records.is_late_card,