From 114efd78b579075be3dd31e02da0115bcd0bb725 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: Mon, 9 Feb 2026 12:17:13 +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 --- .../models/yuthon_vacation_reports.py | 65 +++++++++++-------- .../views/vacation_meal_active_views.xml | 2 +- .../wizard/export_date_wizard.py | 4 +- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index ae6ff5e24..5c0431aeb 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -996,7 +996,7 @@ class YuthonVacationReports(models.Model): 'used_this_year1': last_month_record.used_this_year1, } rec.write(inherit_vals) - if rec.meal_number: + if rec.meal_fee: self._update_meal_lines(rec, [rec], rec.meal_number) if rec.leave: leave_hours = rec.leave * 8 @@ -1957,22 +1957,28 @@ class VacationMealLine(models.Model): rec_month = rec.start_time.month rec.write({'is_filing': True}) emp_id = rec.employee_id.id - meal_active_vals = { - 'line_id': rec.id, - 'meal_name': rec.meal_name, - 'employee_id': emp_id, - 'workflow_id': rec.workflow_id.id if rec.workflow_id else False, - 'start_time': rec.start_time, - 'end_time': rec.end_time, - 'duration': rec.duration, - 'update_lines': rec.update_lines, - 'reasons': rec.reasons, - 'meal': rec.meal, - 'carry_forward_date': fields.Date.today(), - 'carry_forward_state': 'completed', - 'select_revoke': 'to_do' - } - self.env['vacation.meal.active'].create(meal_active_vals) + active_exists = self.env['vacation.meal.active'].search([ + ('line_id', '=', rec.id), + ('employee_id', '=', emp_id), + ('carry_forward_state', '=', 'completed') + ], limit=1) + if not active_exists: + meal_active_vals = { + 'line_id': rec.id, + 'meal_name': rec.meal_name, + 'employee_id': emp_id, + 'workflow_id': rec.workflow_id.id if rec.workflow_id else False, + 'start_time': rec.start_time, + 'end_time': rec.end_time, + 'duration': rec.duration, + 'update_lines': rec.update_lines, + 'reasons': rec.reasons, + 'meal': rec.meal, + 'carry_forward_date': fields.Date.today(), + 'carry_forward_state': 'completed', + 'select_revoke': 'to_do' + } + self.env['vacation.meal.active'].create(meal_active_vals) summary_key = (emp_id, rec_year, rec_month) if summary_key not in emp_month_summary: @@ -1988,15 +1994,22 @@ class VacationMealLine(models.Model): ('vacation_date', '=', fields.Date.from_string(f'{rec_year}-{rec_month}-01')) ], limit=1) if report_id: - self.env['vacation.meal.line'].create([{ - 'vacation_id': report_id.id, - 'employee_id': emp_id, - 'update_type': 'reduce', - 'update_lines': total_amount, - 'update_date': fields.Date.today(), - 'is_void': False, - 'text': f'{rec_month}月份误餐结转', - }]) + over_exists = self.env['vacation.over.line'].search([ + ('vacation_id', '=', report_id.id), + ('employee_id', '=', emp_id), + ('update_type', '=', 'reduce'), + ('text', '=', f'{rec_month}月份误餐结转'), + ], limit=1) + if not over_exists: + self.env['vacation.meal.line'].create([{ + 'vacation_id': report_id.id, + 'employee_id': emp_id, + 'update_type': 'reduce', + 'update_lines': total_amount, + 'update_date': fields.Date.today(), + 'is_void': False, + 'text': f'{rec_month}月份误餐结转', + }]) @api.depends('workflow_record_id') def _compute_overtime(self): diff --git a/yuthon_hr_attendance/views/vacation_meal_active_views.xml b/yuthon_hr_attendance/views/vacation_meal_active_views.xml index 3dfbd3300..f70f17cd3 100644 --- a/yuthon_hr_attendance/views/vacation_meal_active_views.xml +++ b/yuthon_hr_attendance/views/vacation_meal_active_views.xml @@ -6,7 +6,7 @@
-
diff --git a/yuthon_hr_attendance/wizard/export_date_wizard.py b/yuthon_hr_attendance/wizard/export_date_wizard.py index bb5d4834b..c4770e598 100644 --- a/yuthon_hr_attendance/wizard/export_date_wizard.py +++ b/yuthon_hr_attendance/wizard/export_date_wizard.py @@ -10,12 +10,12 @@ class ExportDateWizard(models.TransientModel): _name = 'export.date.wizard' _description = '导出日期选择向导' - year = fields.Integer(string='年份', required=True, default=lambda self: datetime.now().year) + year = fields.Integer(string='结转年份', required=True, default=lambda self: datetime.now().year) month = fields.Selection([ ('1', '1月'), ('2', '2月'), ('3', '3月'), ('4', '4月'), ('5', '5月'), ('6', '6月'), ('7', '7月'), ('8', '8月'), ('9', '9月'), ('10', '10月'), ('11', '11月'), ('12', '12月'), - ], string='月份', required=True, default=lambda self: str(datetime.now().month)) + ], string='结转月份', required=True, default=lambda self: str(datetime.now().month)) export_type = fields.Char(string='导出类型') model_name = fields.Char(string='模型名称')