添加功能
This commit is contained in:
@@ -101,6 +101,96 @@ class YuthonVacationReports(models.Model):
|
||||
tracking=3,
|
||||
default='not_sent')
|
||||
|
||||
def update_overtime(self):
|
||||
today = date.today()
|
||||
over_line_domain = [
|
||||
('vacation_id', '!=', False),
|
||||
('update_type', '=', 'add'),
|
||||
('is_void', '=', False)
|
||||
]
|
||||
over_lines = self.env['vacation.over.line'].search(over_line_domain)
|
||||
|
||||
void_lines = self.env['vacation.over.line']
|
||||
for line in over_lines:
|
||||
# 确定判断超期的基准日期:有adjust_date则用adjust_date,否则用valid_date
|
||||
check_date = line.adjust_date if line.adjust_date else line.valid_date
|
||||
if check_date and today > check_date:
|
||||
void_lines |= line
|
||||
|
||||
# 批量标记作废
|
||||
if void_lines:
|
||||
void_lines.write({'is_void': True})
|
||||
|
||||
for void_line in void_lines:
|
||||
# 跳过vacation_id为空的情况
|
||||
if not void_line.vacation_id:
|
||||
continue
|
||||
|
||||
main_vacation = void_line.vacation_id
|
||||
vacation_date = main_vacation.vacation_date
|
||||
|
||||
# 查找vacation_date之后的加班记录中,text='上月继承额度'的行
|
||||
inherit_domain = [
|
||||
('vacation_id', '=', main_vacation.id),
|
||||
('create_date', '>=', fields.Datetime.to_datetime(vacation_date)),
|
||||
('text', '=', '上月继承额度'),
|
||||
]
|
||||
inherit_lines = self.env['vacation.over.line'].search(inherit_domain)
|
||||
if not inherit_lines:
|
||||
continue
|
||||
|
||||
deduct_value = void_line.workday or 0.0
|
||||
for inherit_line in inherit_lines:
|
||||
new_workday = inherit_line.workday - deduct_value
|
||||
inherit_line.write({'workday': new_workday})
|
||||
|
||||
def update_leave(self):
|
||||
today = date.today()
|
||||
leave_line_domain = [
|
||||
('vacation_id', '!=', False),
|
||||
('update_type', '=', 'add'),
|
||||
('is_void', '=', False)
|
||||
]
|
||||
leave_lines = self.env['vacation.leave.line'].search(leave_line_domain)
|
||||
|
||||
void_lines = self.env['vacation.leave.line']
|
||||
for line in leave_lines:
|
||||
check_date = line.adjust_date if line.adjust_date else line.valid_date
|
||||
if check_date and today > check_date:
|
||||
void_lines |= line
|
||||
|
||||
# 2. 批量标记作废
|
||||
if void_lines:
|
||||
void_lines.write({'is_void': True})
|
||||
|
||||
# 3. 扣减update_lines中「上月继承额度」的workday
|
||||
for void_line in void_lines:
|
||||
if not void_line.vacation_id:
|
||||
continue
|
||||
|
||||
main_vacation = void_line.vacation_id
|
||||
vacation_date = main_vacation.vacation_date
|
||||
if not vacation_date:
|
||||
continue
|
||||
|
||||
# 查找vacation_date之后的年假继承记录(关联update_lines)
|
||||
inherit_domain = [
|
||||
('vacation_id', '=', main_vacation.id),
|
||||
('create_date', '>=', fields.Datetime.to_datetime(vacation_date)),
|
||||
('text', '=', '上月继承额度'),
|
||||
('is_void', '=', False)
|
||||
]
|
||||
inherit_lines = self.env['vacation.leave.line'].search(inherit_domain)
|
||||
|
||||
if not inherit_lines:
|
||||
continue
|
||||
|
||||
# 扣减年假workday
|
||||
deduct_value = void_line.workday or 0.0
|
||||
for inherit_line in inherit_lines:
|
||||
new_workday = inherit_line.workday - deduct_value
|
||||
inherit_line.write({'workday': new_workday})
|
||||
|
||||
@api.depends('other_fee_ids', 'other_fee_ids.holiday_type', 'other_fee_ids.lines',
|
||||
'other_fee_ids.is_void', 'other_fee_ids.update_type', 'parenting_line_ids',
|
||||
'parenting_line_ids.update_date', 'parenting_line_ids.end_date', 'parenting_line_ids.lines')
|
||||
@@ -597,6 +687,18 @@ class YuthonVacationReports(models.Model):
|
||||
'leave': last_month_record.leave,
|
||||
'working_overtime': last_month_record.working_overtime,
|
||||
'medical_fee': last_month_record.medical_fee,
|
||||
'previous_year': last_month_record.previous_year,
|
||||
'valid_date': last_month_record.valid_date,
|
||||
'year_distribution': last_month_record.year_distribution,
|
||||
'used_this_year': last_month_record.used_this_year,
|
||||
'last_holiday': last_month_record.last_holiday,
|
||||
'last_workday': last_month_record.last_workday,
|
||||
'valid_date1': last_month_record.valid_date1,
|
||||
'year_holiday': last_month_record.year_holiday,
|
||||
'year_workday': last_month_record.year_workday,
|
||||
'previous_year1': last_month_record.previous_year1,
|
||||
'used_this_year1': last_month_record.used_this_year1,
|
||||
'remainder_year1': last_month_record.remainder_year1,
|
||||
}
|
||||
rec.write(inherit_vals)
|
||||
if rec.leave:
|
||||
@@ -733,9 +835,9 @@ class YuthonVacationReports(models.Model):
|
||||
)
|
||||
def _compute_working_overtime(self):
|
||||
for record in self:
|
||||
total_add1 = 0.0
|
||||
total_add2 = 0.0
|
||||
total_add = 0.0
|
||||
total_add1 = 0.0 # 加班时
|
||||
total_add2 = 0.0 # (已用补休)
|
||||
total_add = 0.0 # (剩余补休)
|
||||
legal_total = 0.0
|
||||
for line in record.overtime_ids:
|
||||
if line.is_void:
|
||||
@@ -750,8 +852,10 @@ class YuthonVacationReports(models.Model):
|
||||
|
||||
if line.workflow_record_id and line.update_type == 'add' and line.overtime_methods == 'leave':
|
||||
total_add1 += line_total
|
||||
|
||||
if line.workflow_record_id and line.update_type == 'reduce':
|
||||
total_add2 += line_total
|
||||
|
||||
adjust_holiday_days = 0.0
|
||||
for other_line in record.other_fee_ids:
|
||||
if other_line.holiday_type and other_line.holiday_type.name == '调休':
|
||||
@@ -856,6 +960,7 @@ class YuthonVacationReports(models.Model):
|
||||
continue
|
||||
self.env['vacation.leave.line'].create({
|
||||
'vacation_id': report.id,
|
||||
'valid_date': report.valid_date,
|
||||
'employee_id': report.employee_id.id,
|
||||
'update_type': 'add',
|
||||
'update_date': fields.Date.today(),
|
||||
@@ -878,6 +983,7 @@ class YuthonVacationReports(models.Model):
|
||||
self.env['vacation.over.line'].create({
|
||||
'vacation_id': report.id,
|
||||
'employee_id': report.employee_id.id,
|
||||
'valid_date': report.valid_date1,
|
||||
'update_type': 'add',
|
||||
'update_date': fields.Date.today(),
|
||||
'workday': number_of_hours_display,
|
||||
@@ -1026,7 +1132,7 @@ class VacationOverline(models.Model):
|
||||
remaining_quantity = fields.Float(string='剩余数', compute="_compute_remaining_quantity", store=True)
|
||||
|
||||
def open_record1(self):
|
||||
tree_id = self.env.ref("yuthon_vacation_reports.view_yuthon_vacation_overtime_tree").id
|
||||
tree_id = self.env.ref("yuthon_hr_attendance.view_yuthon_vacation_overtime_tree").id
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': 'Overtime Record',
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
<field name="model">yuthon.vacation.reports</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="假期额度记录" editable="bottom" edit="0" default_order="vacation_date desc" js_class="custom_vacation_put_button" limit="10">
|
||||
<header>
|
||||
<button name="manage_confirmation" type="object" string="批量确认" dclass="oe_highlight"/>
|
||||
</header>
|
||||
<field name="vacation_state" widget="badge" decoration-info="vacation_state == 'not_sent'"
|
||||
decoration-success="vacation_state == 'confirmed'"/>
|
||||
<field name="employee_id" options="{'no_open': True}"/>
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<field name="meal_allowance" string="误餐费"/>
|
||||
<field name="reimbursed_medical_exam_fee" string="已报销体检费"/>
|
||||
<field name="remaining_medical_exam_fee" string="剩余体检费"/>
|
||||
<field name="confirm_status"/>
|
||||
<field name="confirm_status" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -87,7 +87,7 @@
|
||||
<field name="model">yuthon.salary.active</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="我的薪资" create="false" delete="false" edit="false">
|
||||
<button name="salary_confirm" string="确认" type="object" class="oe_highlight"/>
|
||||
<button name="salary_confirm" string="确认" type="object" class="oe_highlight" invisible="confirm_status == 'confirm'"/>
|
||||
<button name="open_archive_record" string="详情" type="object" class="oe_highlight"/>
|
||||
<field name="select_year"/>
|
||||
<field name="select_time"/>
|
||||
@@ -98,6 +98,7 @@
|
||||
<field name="enterprise_annuity" string="年金"/>
|
||||
<field name="trade_union_dues" string="工会费"/>
|
||||
<field name="meal_allowance"/>
|
||||
<field name="confirm_status" column_invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user