From ef7a17811f4567fd119d19b189732d1b1489c0f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Fri, 30 Jan 2026 14:32:06 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
yuthon_base/__manifest__.py | 1 +
yuthon_base/models/__init__.py | 3 +-
yuthon_base/models/base_month_year.py | 22 +++++++++++++
yuthon_base/security/ir.model.access.csv | 4 ++-
yuthon_base/views/base_month_year_views.xml | 31 +++++++++++++++++++
yuthon_base/views/menu.xml | 10 ++++++
yuthon_holiday/views/hr_leave_batch.xml | 4 +--
.../models/yuthon_vacation_reports.py | 8 ++++-
.../views/yuthon_vacation_reports_views.xml | 4 ++-
9 files changed, 81 insertions(+), 6 deletions(-)
create mode 100644 yuthon_base/models/base_month_year.py
create mode 100644 yuthon_base/views/base_month_year_views.xml
diff --git a/yuthon_base/__manifest__.py b/yuthon_base/__manifest__.py
index c7ff83e86..4fc7c3955 100644
--- a/yuthon_base/__manifest__.py
+++ b/yuthon_base/__manifest__.py
@@ -12,6 +12,7 @@
'views/ir_cron_act_views.xml',
'views/yuthon_timed_tasks_views.xml',
'views/yuthon_timed_tasks_views.xml',
+ 'views/base_month_year_views.xml',
'views/yuthon_phone_lotter.xml',
'views/menu.xml',
],
diff --git a/yuthon_base/models/__init__.py b/yuthon_base/models/__init__.py
index b39548246..f3bf7120c 100644
--- a/yuthon_base/models/__init__.py
+++ b/yuthon_base/models/__init__.py
@@ -5,4 +5,5 @@ from . import fields_piyin
from . import ir_cron_act
from . import yuthon_timed_tasks
from . import yuthon_phone_lottery
-from . import res_partner
\ No newline at end of file
+from . import res_partner
+from . import base_month_year
\ No newline at end of file
diff --git a/yuthon_base/models/base_month_year.py b/yuthon_base/models/base_month_year.py
new file mode 100644
index 000000000..46da428a5
--- /dev/null
+++ b/yuthon_base/models/base_month_year.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+from datetime import datetime, timedelta, time
+from email.policy import default
+
+from odoo import models, fields, api, _
+from odoo.exceptions import UserError, ValidationError
+import re
+from odoo.tools.misc import format_date
+
+
+class BaseYearMonth(models.Model):
+ _name = 'base.year'
+ _description = '系统年份'
+
+ name = fields.Integer(string='年', required=True)
+
+
+class BaseMonth(models.Model):
+ _name = 'base.month'
+ _description = '系统月份'
+
+ name = fields.Integer(string='月', required=True)
diff --git a/yuthon_base/security/ir.model.access.csv b/yuthon_base/security/ir.model.access.csv
index 6489e8400..5de4e65d4 100644
--- a/yuthon_base/security/ir.model.access.csv
+++ b/yuthon_base/security/ir.model.access.csv
@@ -3,4 +3,6 @@ access_system_version,system_version,model_system_version,base.group_system,1,1,
access_ir_cron_type,ir.cron.type,model_ir_cron_type,base.group_system,1,1,1,1
access_yuthon_timed_tasks,yuthon.timed.tasks,model_yuthon_timed_tasks,base.group_system,1,1,1,1
access_users_home_batch_wizard,access_users_home_batch_wizard,model_users_home_batch_wizard,base.group_user,1,1,1,1
-access_phone_lottery,phone.lottery,model_phone_lottery,base.group_user,1,1,1,1
\ No newline at end of file
+access_phone_lottery,phone.lottery,model_phone_lottery,base.group_user,1,1,1,1
+access_base_year,base.year,model_base_year,base.group_system,1,1,1,1
+access_base_month,base.month,model_base_month,base.group_system,1,1,1,1
\ No newline at end of file
diff --git a/yuthon_base/views/base_month_year_views.xml b/yuthon_base/views/base_month_year_views.xml
new file mode 100644
index 000000000..07eddf597
--- /dev/null
+++ b/yuthon_base/views/base_month_year_views.xml
@@ -0,0 +1,31 @@
+
+
+
+ base.year.tree
+ base.year
+
+
+
+
+
+
+
+ base.month.tree
+ base.month
+
+
+
+
+
+
+
+ 年份配置
+ base.year
+ tree
+
+
+ 月份配置
+ base.month
+ tree
+
+
diff --git a/yuthon_base/views/menu.xml b/yuthon_base/views/menu.xml
index 61740d213..b4d103ee2 100644
--- a/yuthon_base/views/menu.xml
+++ b/yuthon_base/views/menu.xml
@@ -33,4 +33,14 @@
parent="cron_type_menu_root"
action="view_yuthon_lottery_action"
sequence="10"/>
+
+
\ No newline at end of file
diff --git a/yuthon_holiday/views/hr_leave_batch.xml b/yuthon_holiday/views/hr_leave_batch.xml
index ccb5e5946..917cd8a93 100644
--- a/yuthon_holiday/views/hr_leave_batch.xml
+++ b/yuthon_holiday/views/hr_leave_batch.xml
@@ -54,9 +54,9 @@
-
-
+
diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py
index 8e2657b43..30bb1fc15 100644
--- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py
+++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py
@@ -15,6 +15,8 @@ class YuthonVacationReports(models.Model):
_rec_name = "employee_id"
_order = "vacation_date desc"
+ month_id = fields.Many2one('base.month', string='月份', compute="_compute_display_date", store=True)
+ year_id = fields.Many2one('base.year', string='年份', compute="_compute_display_date", store=True)
employee_id = fields.Many2one('hr.employee', string='员工')
number_card = fields.Integer(string='补卡次数')
salary_group_id = fields.Many2one(related='employee_id.salary_group_id', string="工资单分组", store=True)
@@ -359,8 +361,12 @@ class YuthonVacationReports(models.Model):
@api.depends('vacation_date')
def _compute_display_date(self):
for rec in self:
- rec.show_date = rec.vacation_date + relativedelta(months=1)
+ rec.show_date = rec.vacation_date
rec.display_date = (rec.vacation_date).strftime('%Y年%m月')
+ month_id = rec.env['base.month'].search([('name', '=', int(rec.vacation_date.month))])
+ rec.month_id = month_id.id
+ year_id = rec.env['base.year'].search([('name', '=', int(rec.vacation_date.year))])
+ rec.year_id = year_id.id
@api.depends('employee_id', 'vacation_date')
def compute_attendance_fields(self):
diff --git a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml
index 63ea04d8d..bc17aa019 100644
--- a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml
+++ b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml
@@ -42,6 +42,7 @@
+
@@ -432,7 +433,8 @@
context="{'group_by': 'show_date:month'}"/>