!4310 添加功能

Merge pull request !4310 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-08-05 07:10:17 +00:00
committed by Gitee
5 changed files with 62 additions and 3 deletions
+1
View File
@@ -9,6 +9,7 @@
'security/ir.model.access.csv',
'security/yuthon_holiday_group.xml',
'data/yuthon_holiday_data.xml',
'data/mothly_report_time.xml',
'views/inherit_hr_type_views.xml',
'views/inherit_hr_leave_allocation_views.xml',
'views/inherit_hr_leave_accrual_plan_views.xml',
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data noupdate="1">
<record forcecreate="True" id="yuthon_vacation_start_end_time" model="ir.cron">
<field name="name">定时任务:生成我的考勤确认单</field>
<field name="model_id" ref="model_yuthon_vacation_reports"/>
<field name="state">code</field>
<field name="code">model.monthly_report()</field>
<field eval="False" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">months</field>
<field name="nextcall" eval="(DateTime.now()).strftime('%Y-%m-%d 00:00:00')"/>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
</record>
</data>
</odoo>
@@ -38,6 +38,39 @@ class YuthonVacationReports(models.Model):
record.medical_fee = max(total, 0.0)
def monthly_report(self):
today = fields.Date.today()
employees = self.env['hr.employee'].search([])
for employee in employees:
existing_record = self.search([
('employee_id', '=', employee.id),
('vacation_date', '=', today)
], limit=1)
if not existing_record:
self.create({
'employee_id': employee.id,
'vacation_date': today,
# 明细行和计算字段留空,由后续逻辑处理
})
def disposable_report(self):
year = 2025
months = range(1, 8) # 1到7月
employees = self.env['hr.employee'].search([])
for month in months:
report_date = fields.Date.from_string(f"{year}-{month:02d}-01")
for employee in employees:
existing = self.search([
('employee_id', '=', employee.id),
('vacation_date', '=', report_date)
], limit=1)
if not existing:
self.create({
'employee_id': employee.id,
'vacation_date': report_date,
# 计算字段会自动触发,无需手动设置
})
def overtime_allocation(self):
form_id = self.env.ref('hr_holidays.hr_leave_allocation_view_form_manager').id
holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '补休')])
@@ -10,6 +10,7 @@
<field name="working_overtime"/>
<field name="meal_fee"/>
<field name="company_id" optional="hide"/>
<field name="vacation_date"/>
<button name="button_fixes_approval" string="修正" type="object" class="oe_highlight"/>
<button name="log" string="日志" type="object" class="oe_highlight"/>
</tree>
@@ -152,6 +153,10 @@
<field name="arch" type="xml">
<search>
<field name="employee_id"/>
<group expand="0" string="Group By">
<filter string="员工" name="group_by_employee_id" domain="[]" context="{'group_by': 'employee_id'}"/>
<filter string="日期" name="group_by_vacation_date" domain="[]" context="{'group_by' : 'vacation_date'}"/>
</group>
</search>
</field>
</record>
@@ -263,15 +268,17 @@
<field name="name">假期额度日志</field>
<field name="res_model">yuthon.vacation.reports</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_group_by_employee_id': 1, 'search_default_group_by_vacation_date': True}</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_holiday.view_yuthon_vacation_reports_tree')}),
(0, 0, {'view_mode': 'form', 'view_id': ref('yuthon_holiday.view_yuthon_vacation_reports_form')})]"/>
</record>
<record id="action_server_open_my_vacation_form1" model="ir.actions.act_window">
<field name="name">我的假期额度表单</field>
<field name="name">我的考勤确认</field>
<field name="res_model">yuthon.vacation.reports</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('employee_id.user_id', '=', uid)]</field>
<field name="context">{'search_default_group_by_vacation_date': 1}</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_holiday.view_yuthon_vacation_my_reports_tree')}),
(0, 0, {'view_mode': 'form', 'view_id': ref('yuthon_holiday.view_yuthon_vacation_reports_form1')})]"/>
@@ -302,7 +309,7 @@
<field name="model_id" ref="yuthon_holiday.model_yuthon_vacation_reports"/>
<field name="binding_model_id" ref="yuthon_holiday.model_yuthon_vacation_reports"/>
<field name="state">code</field>
<field name="code">action = model.batch_compute_leave_and_overtime()</field>
<field name="code">action = model.disposable_report()</field>
</record>
<record id="details_tree_view" model="ir.ui.view">
<field name="name">details.tree.tree</field>
+1 -1
View File
@@ -628,7 +628,7 @@
action="yuthon_hr_attendance.hr_attendance_my_abnormal"
sequence="6"/>
<menuitem id="yuthon_vacation_reports_my"
name="我的假期额度"
name="我的考勤确认"
parent="holiday_manage_menu_root_board"
action="yuthon_holiday.action_server_open_my_vacation_form1"
sequence="7"/>