From dbf89279c654f9d7d8da4479c95c351aa7fa394e Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Mon, 2 Jun 2025 21:25:04 +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/inherit_hr_leave_allocation.py | 31 +++++++++++++---
.../models/yuthon_vacation_reports.py | 36 +++++++++++++++++--
.../inherit_hr_leave_allocation_views.xml | 6 ++--
.../views/yuthon_vacation_reports_views.xml | 10 +++++-
.../models/inherit_hr_payslip_run.py | 9 +++--
.../views/inherit_hr_payslip_run_views.xml | 2 +-
6 files changed, 80 insertions(+), 14 deletions(-)
diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py
index 4f39ad5cb..056bfa4f1 100644
--- a/yuthon_holiday/models/inherit_hr_leave_allocation.py
+++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py
@@ -97,8 +97,29 @@ class HrLeaveAllocation(models.Model):
"target": "new",
}
- def allocation_date(self):
- date = datetime(2025, 1, 1)
- leave_id = self.env['hr.leave.allocation'].search([])
- for record in leave_id:
- leave_id.sudo().write({'date_from': date})
\ No newline at end of file
+ def update_employee(self):
+ leave_ids = self.env["hr.leave.allocation"].browse(
+ self._context.get('active_ids', self._context.get('active_id')))
+ for leave in leave_ids:
+ leave.employee_id.write({'remainder_year': leave.number_of_hours_display,
+ 'quota_issued': leave.number_of_hours_display})
+
+ @api.model
+ def create(self, vals):
+ # 调用原始创建方法获取记录
+ allocation = super(HrLeaveAllocation, self).create(vals)
+ if allocation.holiday_status_id.name == '年假':
+ employee = allocation.employee_id
+ days = allocation.number_of_hours_display
+ # 累计员工字段
+ employee.write({
+ 'remainder_year': employee.remainder_year + days,
+ 'quota_issued': employee.quota_issued + days
+ })
+ return allocation
+
+ # def allocation_date(self):
+ # date = datetime(2025, 1, 1)
+ # leave_id = self.env['hr.leave.allocation'].search([])
+ # for record in leave_id:
+ # leave_id.sudo().write({'date_from': date})
\ No newline at end of file
diff --git a/yuthon_holiday/models/yuthon_vacation_reports.py b/yuthon_holiday/models/yuthon_vacation_reports.py
index d88d76c4e..05509abd1 100644
--- a/yuthon_holiday/models/yuthon_vacation_reports.py
+++ b/yuthon_holiday/models/yuthon_vacation_reports.py
@@ -9,6 +9,7 @@ class YuthonVacationReports(models.Model):
_description = '假期报表'
employee_id = fields.Many2one('hr.employee', string='员工')
+ company_id = fields.Many2one(related="employee_id.company_id", string="公司")
leave = fields.Float(string='年假')
working_overtime = fields.Float(string='加班时')
meal_fee = fields.Integer(string="误餐费")
@@ -29,12 +30,43 @@ class YuthonVacationReports(models.Model):
}
def vacation_details(self):
- domain =[('workflow_id.name', '=', '请假'), ('create_uid', '=', self.employee_id.user_id.id)]
+ domain =[('workflow_id.name', 'in', ['请假', '加班', '外出']), ('create_uid', '=', self.employee_id.user_id.id)]
action = {
'name': '审批详情',
'type': 'ir.actions.act_window',
'res_model': 'soong.workflow.record',
'view_mode': 'tree',
'domain': domain,
+ 'context': {'group_by': ['workflow_id']}
}
- return action
\ No newline at end of file
+ return action
+
+ def update_vacation(self):
+ employees = self.env['hr.employee'].search([
+ ('is_salary', '=', True),
+ ('contract_id.state', '!=', 'cancel'),
+ ('contract_id', '!=', False),
+ ])
+ for employee in employees:
+ vacation_id = self.env['yuthon.vacation.reports'].search([
+ ('employee_id', '=', employee.id),
+ ])
+ if not vacation_id:
+ self.env['yuthon.vacation.reports'].create({
+ 'employee_id': employee.id,
+ 'leave': employee.remainder_year,
+ 'working_overtime': employee.overtime_this_month,
+ 'meal_fee': employee.meal_number,
+ })
+ else:
+ vacation_id.write({
+ 'leave': employee.remainder_year,
+ 'working_overtime': employee.overtime_this_month,
+ 'meal_fee': employee.meal_number,
+ })
+
+
+
+
+
+
diff --git a/yuthon_holiday/views/inherit_hr_leave_allocation_views.xml b/yuthon_holiday/views/inherit_hr_leave_allocation_views.xml
index daf95447f..56fc6fd17 100644
--- a/yuthon_holiday/views/inherit_hr_leave_allocation_views.xml
+++ b/yuthon_holiday/views/inherit_hr_leave_allocation_views.xml
@@ -62,11 +62,11 @@
code
action = model.action_uninstall_wizard()
-
- 初始化时间
+
+ 一次性更新
code
- action = model.allocation_date()
+ action = model.update_employee()
\ No newline at end of file
diff --git a/yuthon_holiday/views/yuthon_vacation_reports_views.xml b/yuthon_holiday/views/yuthon_vacation_reports_views.xml
index ad0b1e024..ed9f2284e 100644
--- a/yuthon_holiday/views/yuthon_vacation_reports_views.xml
+++ b/yuthon_holiday/views/yuthon_vacation_reports_views.xml
@@ -5,10 +5,11 @@
yuthon.vacation.reports
-
+
+
@@ -19,5 +20,12 @@
yuthon.vacation.reports
tree
+
+ 更新报表
+
+
+ code
+ action = model.update_vacation()
+
diff --git a/yuthon_salary/models/inherit_hr_payslip_run.py b/yuthon_salary/models/inherit_hr_payslip_run.py
index c4b295ecf..b42afc067 100644
--- a/yuthon_salary/models/inherit_hr_payslip_run.py
+++ b/yuthon_salary/models/inherit_hr_payslip_run.py
@@ -10,7 +10,6 @@ class InheritHrPayslipRun(models.Model):
document_ids = fields.Many2many('ir.attachment', string="附件")
-
def Fileline(self):
domain = [('is_salary_push', '=', True), ('is_salary_release', '=', True)]
return {
@@ -21,6 +20,12 @@ class InheritHrPayslipRun(models.Model):
"domain": domain,
}
+ @api.onchange('document_ids')
+ def _onchange_document_ids(self):
+ for rec in self:
+ if rec.document_ids:
+ rec.state = 'verify'
def add_comment(self):
- pass
+ for rec in self:
+ rec.state = 'close'
diff --git a/yuthon_salary/views/inherit_hr_payslip_run_views.xml b/yuthon_salary/views/inherit_hr_payslip_run_views.xml
index 98ec20160..14b1e8e20 100644
--- a/yuthon_salary/views/inherit_hr_payslip_run_views.xml
+++ b/yuthon_salary/views/inherit_hr_payslip_run_views.xml
@@ -11,7 +11,7 @@
-
+