导出,过滤

This commit is contained in:
李鹏宇
2026-04-14 18:59:14 +08:00
parent c4fd082570
commit 87ee1e6a44
4 changed files with 23 additions and 30 deletions
@@ -250,24 +250,6 @@ class YuthonVacationReports(models.Model):
# 保留第一个,删除后面的
to_delete.extend(report_list[1:])
def reset_march_2026_to_pending(self):
"""将2026年3月的考勤确认单状态重置为已确认"""
reports = self.env['yuthon.vacation.reports'].search([
('show_date', '>=', '2026-03-01'),
('show_date', '<=', '2026-03-31'),
])
reports.write({'vacation_state': 'pending'})
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': '操作成功',
'message': f'已将 {len(reports)} 条2026年3月数据状态重置为已确认',
'type': 'success',
'sticky': False,
}
}
@api.model
def leave_line(self):
today = date.today()
@@ -49,7 +49,6 @@
<header>
<button name="manage_confirmation" type="object" string="批量确认" class="oe_highlight"/>
<button name="cleanup_march_2026" type="object" string="删除测试" class="oe_highlight"/>
<button name="reset_march_2026_to_pending" type="object" string="重置3月为待确认" class="oe_highlight"/>
</header>
<field name="vacation_state" widget="badge" decoration-info="vacation_state == 'not_sent'"
decoration-success="vacation_state == 'confirmed'"/>
@@ -2,7 +2,7 @@
from odoo import fields, models
import json
from odoo.tools import date_utils
from datetime import datetime
from datetime import datetime, timedelta
from odoo.exceptions import UserError
@@ -234,8 +234,8 @@ class ExportDateWizard(models.TransientModel):
row_data = {
'employee_id': over_line.employee_id.name if over_line and over_line.employee_id else '',
'department_id': over_line.department_id.name if over_line and over_line.department_id else '',
'start_time': over_line.start_time if over_line else '',
'end_time': over_line.end_time if over_line else '',
'start_time': (over_line.start_time + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S') if over_line and over_line.start_time else '',
'end_time': (over_line.end_time + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S') if over_line and over_line.end_time else '',
'carry_forward_date': record.carry_forward_date,
'carry_forward_quantity': record.carry_forward_quantity,
'carry_forward_state': carry_forward_state_value
@@ -317,19 +317,31 @@ class ExportDateWizard(models.TransientModel):
if not filtered_records:
raise UserError(f'在 {self.year} 年 {self.month} 月没有找到符合条件的误餐归档记录')
filtered_ids = filtered_records.ids
fields_name = ['employee_id', 'department_id', 'workflow_id', 'start_time',
'end_time', 'duration', 'reasons', 'meal']
field_label = ['发起人', '部门', '审批类型', '加班开始时间', '加班结束时间',
'加班时长', '事由', '加班餐费']
export_data = []
for record in filtered_records:
export_data.append({
'employee_id': record.employee_id.name if record.employee_id else '',
'department_id': record.department_id.name if record.department_id else '',
'workflow_id': record.workflow_id.name if record.workflow_id else '',
'start_time': (record.start_time + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S') if record.start_time else '',
'end_time': (record.end_time + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S') if record.end_time else '',
'duration': record.duration,
'update_lines': record.update_lines,
'reasons': record.reasons or '',
'meal': record.meal,
})
fields_name = ['employee_id', 'department_id', 'workflow_id', 'start_time',
'end_time', 'duration', 'update_lines', 'reasons', 'meal']
field_label = ['发起人', '部门', '审批类型', '加班开始时间', '加班结束时间',
'加班时长', '额度', '事由', '加班餐费']
data = {
'report_name': '误餐归档明细报表',
'model_name': 'vacation.meal.active',
'fields_name': fields_name,
'field_label': field_label,
'active_ids': filtered_ids,
'export_data': export_data,
}
return {
@@ -10,7 +10,7 @@
<field name="start_index"/>
<field name="refund_type"/>
<field name="payment_unit_ids" widget="many2many_tags"/>
<field name="pay_unit_id"/>
<field name="pay_unit_id" domain="[('start_data', '&lt;=', start_index)]"/>
</group>
<field name="refund_line_ids" string="退款明细">
<tree editable="bottom" create="1" edit="1" delete="1">