!9860 Merge branch 'dev' of <a href="https://gitee.com/jinan-pengyusen-data/gzth">https://gitee.com/jinan-pengyusen-data/gzth</a> into dev_wang
Merge pull request !9860 from 李鹏宇/dev_wang
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
<field name="model">yuthon.meal.expenses</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="餐费" editable="bottom" js_class="custom_meal_button">
|
||||
<header>
|
||||
<button name="action_generate_missing_feb" string="批量生成2026年2月缺失数据" type="object" class="btn btn-blue"/>
|
||||
</header>
|
||||
<field name="select_year"/>
|
||||
<field name="select_time"/>
|
||||
<field name="employee_id"/>
|
||||
|
||||
Reference in New Issue
Block a user