diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index eed954d38..2c86249d7 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -192,7 +192,6 @@ class YuthonVacationReports(models.Model): 'duty_date': duty_date, 'is_adjustment': False }) - # 批量创建(效率更高) if create_vals: duty_schedule_env.create(create_vals) record.duty_ids = duty_schedule_env.search([ @@ -201,7 +200,6 @@ class YuthonVacationReports(models.Model): ('duty_date', '<=', month_end) ]) - @api.depends('duty_ids.is_adjustment') def _compute_duty_fee(self): for record in self: @@ -1247,6 +1245,23 @@ class YuthonVacationReports(models.Model): day = day.lstrip('0') return f'{month}月{day}日' + @api.model + def put_vacation(self): + today = fields.Date.today() + first_day = today.replace(day=1) + last_month_first = first_day - relativedelta(months=1) + report_objs = self.env['yuthon.vacation.reports'].search([ + ('vacation_date', '=', last_month_first), + ('vacation_state', '=', 'not_sent'), + ]) + for report in report_objs: + resource_user_ids = report.employee_id.resource_calendar_id.resource_user_ids.ids + if report.employee_id.id in resource_user_ids: + report.write({'vacation_state': 'confirmed'}) + else: + report.button_put() + + def att_button_put_task(self): today = fields.Date.today() first_day = today.replace(day=1) diff --git a/yuthon_hr_attendance/static/src/js/button_vacation_put.js b/yuthon_hr_attendance/static/src/js/button_vacation_put.js index a4fb129a1..418ee9608 100644 --- a/yuthon_hr_attendance/static/src/js/button_vacation_put.js +++ b/yuthon_hr_attendance/static/src/js/button_vacation_put.js @@ -22,6 +22,11 @@ export class CustomAttendanceVacationPutController extends ListController { const res = await this.orm.call('yuthon.vacation.reports', 'meal_line', []); this.actionService.doAction(res) } + + async getPutAction() { + const res = await this.orm.call('yuthon.vacation.reports', 'put_vacation', []); + this.actionService.doAction(res) + } } registry.category("views").add("custom_vacation_put_button", { diff --git a/yuthon_hr_attendance/static/src/xml/button_vacation_put.xml b/yuthon_hr_attendance/static/src/xml/button_vacation_put.xml index 8dc2e1203..bd03b5759 100644 --- a/yuthon_hr_attendance/static/src/xml/button_vacation_put.xml +++ b/yuthon_hr_attendance/static/src/xml/button_vacation_put.xml @@ -16,5 +16,10 @@ 误餐情况 + + +