!8297 出勤接口

Merge pull request !8297 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2026-01-25 14:31:31 +00:00
committed by Gitee
+15 -2
View File
@@ -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,