From f1c434d1607317d2337287730cc698f5070cb382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Tue, 17 Mar 2026 21:35:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A4=90=E9=A5=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_salary/models/yuthon_meal_expenses.py | 34 +++++++++++++++++++ .../views/yuthon_meal_expenses_views.xml | 3 ++ 2 files changed, 37 insertions(+) diff --git a/yuthon_salary/models/yuthon_meal_expenses.py b/yuthon_salary/models/yuthon_meal_expenses.py index 6f24f4124..d5419a19d 100644 --- a/yuthon_salary/models/yuthon_meal_expenses.py +++ b/yuthon_salary/models/yuthon_meal_expenses.py @@ -79,6 +79,40 @@ class YuthonMealExpenses(models.Model): }, } + def action_generate_missing_feb(self): + target_year = '2026' + target_month = '2' + # 取全部参餐员工 + all_confs = self.env['yuthon.catering.conf'].search([]) + all_employees = all_confs.mapped('employee_ids') + # 已有记录的员工 + existing = self.search([ + ('select_year', '=', target_year), + ('select_time', '=', target_month), + ]) + existing_emp_ids = existing.mapped('employee_id').ids + # 批量创建缺失记录 + created = 0 + for emp in all_employees: + if emp.id not in existing_emp_ids: + self.create({ + 'employee_id': emp.id, + 'card': emp.identification_id or '', + 'select_year': target_year, + 'select_time': target_month, + }) + created += 1 + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': '生成完成', + 'message': '共生成2026年2月缺失数据 %d 条' % created, + 'type': 'success', + 'sticky': False, + } + } + def action_view_detail(self): self.ensure_one() date_start, date_end = self._get_date_range() diff --git a/yuthon_salary/views/yuthon_meal_expenses_views.xml b/yuthon_salary/views/yuthon_meal_expenses_views.xml index f8a8f0be0..26a154c58 100644 --- a/yuthon_salary/views/yuthon_meal_expenses_views.xml +++ b/yuthon_salary/views/yuthon_meal_expenses_views.xml @@ -24,6 +24,9 @@ yuthon.meal.expenses +
+