@@ -148,6 +148,47 @@ class HrLeave(models.Model):
|
||||
('22', '22:00'), ('22.5', '22:30'),
|
||||
('23', '23:00'), ('23.5', '23:30')], string='结束时间')
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
allocation = super(HrLeave, self).create(vals)
|
||||
if allocation.holiday_status_id.name == '年假' and allocation.state == 'validate':
|
||||
employee = allocation.employee_id
|
||||
days = allocation.number_of_days * 8
|
||||
employee.write({
|
||||
'user_year': employee.user_year + days
|
||||
})
|
||||
reports_id = self.env['yuthon.vacation.reports'].search([
|
||||
('employee_id', '=', employee.id)
|
||||
], limit=1)
|
||||
# 创建假期明细记录
|
||||
self.env['vacation.leave.line'].create({
|
||||
'vacation_id': reports_id.id,
|
||||
'update_type': 'reduce',
|
||||
'update_date': fields.Datetime.now(),
|
||||
'update_lines': days,
|
||||
'text': '休假',
|
||||
'allocation_type': 'vacation',
|
||||
})
|
||||
return allocation
|
||||
|
||||
def unlink(self):
|
||||
for record in self:
|
||||
if record.employee_id and record.holiday_status_id.name == '年假':
|
||||
employee = record.employee_id
|
||||
days = record.number_of_hours_display
|
||||
lines_to_delete = self.env['vacation.leave.line'].search([
|
||||
('vacation_id.employee_id', '=', employee.id),
|
||||
('update_type', '=', 'reduce'),
|
||||
('update_lines', '=', days),
|
||||
('allocation_type', '=', 'vacation'),
|
||||
])
|
||||
if lines_to_delete:
|
||||
lines_to_delete.is_void = True
|
||||
employee.write({
|
||||
'user_year': employee.user_year - days
|
||||
})
|
||||
return super(HrLeave, self).unlink()
|
||||
|
||||
@api.depends('request_hour_from')
|
||||
def _compute_request_hour_from_real(self):
|
||||
for record in self:
|
||||
|
||||
@@ -105,10 +105,8 @@ class HrLeaveAllocation(models.Model):
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
# 调用原始创建方法获取记录
|
||||
allocation = super(HrLeaveAllocation, self).create(vals)
|
||||
# 处理年假类型的分配
|
||||
if allocation.holiday_status_id.name == '年假':
|
||||
if allocation.holiday_status_id.name == '年假' and allocation.state == 'validate':
|
||||
employee = allocation.employee_id
|
||||
days = allocation.number_of_hours_display
|
||||
employee.write({
|
||||
@@ -118,11 +116,12 @@ class HrLeaveAllocation(models.Model):
|
||||
('employee_id', '=', employee.id)
|
||||
], limit=1)
|
||||
# 创建假期明细记录
|
||||
self.env['yuthon.vacation.line'].create({
|
||||
self.env['vacation.leave.line'].create({
|
||||
'vacation_id': reports_id.id,
|
||||
'update_type': 'add',
|
||||
'update_date': fields.Datetime.now(),
|
||||
'update_lines': days,
|
||||
'allocation_type': 'allocation',
|
||||
'text': allocation.name
|
||||
})
|
||||
return allocation
|
||||
@@ -134,14 +133,15 @@ class HrLeaveAllocation(models.Model):
|
||||
if record.employee_id and record.holiday_status_id.name == '年假':
|
||||
employee = record.employee_id
|
||||
days = record.number_of_hours_display
|
||||
lines_to_delete = self.env['yuthon.vacation.line'].search([
|
||||
lines_to_delete = self.env['vacation.leave.line'].search([
|
||||
('vacation_id.employee_id', '=', employee.id),
|
||||
('update_type', '=', 'add'),
|
||||
('update_lines', '=', days),
|
||||
('allocation_type', '=', 'allocation'),
|
||||
('text', '=', record.name)
|
||||
])
|
||||
if lines_to_delete:
|
||||
lines_to_delete.unlink()
|
||||
lines_to_delete.is_void = True
|
||||
employee.write({
|
||||
'quota_issued': employee.quota_issued - days
|
||||
})
|
||||
|
||||
@@ -18,6 +18,22 @@ class YuthonVacationReports(models.Model):
|
||||
working_overtime = fields.Float(string='加班时', compute='_compute_working_overtime', store=True)
|
||||
meal_fee = fields.Integer(string="误餐次数", compute='_compute_meal_fee', store=True)
|
||||
|
||||
def vacation_delete(self):
|
||||
vacation_ids = self.env["yuthon.vacation.reports"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for record in vacation_ids:
|
||||
for leave in record.leave_ids:
|
||||
leave.unlink()
|
||||
for overtime in record.overtime_ids:
|
||||
overtime.unlink()
|
||||
for meal_fee in record.meal_fee_ids:
|
||||
meal_fee.unlink()
|
||||
record.write({
|
||||
'leave': 0.0,
|
||||
'working_overtime': 0.0,
|
||||
'meal_fee': 0,
|
||||
})
|
||||
|
||||
@api.depends('leave_ids.update_lines', 'leave_ids.update_type')
|
||||
def _compute_leave(self):
|
||||
for record in self:
|
||||
@@ -132,10 +148,13 @@ class VacationLeaveLine(models.Model):
|
||||
_description = '年假明细'
|
||||
|
||||
vacation_id = fields.Many2one('yuthon.vacation.reports', string='关联假期额度记录')
|
||||
employee_id = fields.Many2one('hr.employee', string='员工')
|
||||
workflow_record_id = fields.Many2one('soong.workflow.record', string='流程')
|
||||
update_type= fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型')
|
||||
update_date = fields.Date(string='更新时间')
|
||||
update_lines = fields.Float(string='更新额度')
|
||||
is_void = fields.Boolean(string='是否作废')
|
||||
allocation_type = fields.Selection([('vacation', '休假'), ('allocation', '分配')], string='分配类型')
|
||||
text = fields.Text(string='备注')
|
||||
|
||||
@api.model
|
||||
@@ -148,9 +167,14 @@ class VacationLeaveLine(models.Model):
|
||||
"""
|
||||
sign = -1 if reverse else 1
|
||||
employee = self.vacation_id.employee_id
|
||||
employee.write({
|
||||
'user_year': employee.user_year + self.update_lines * sign,
|
||||
})
|
||||
if self.allocation_type == 'vacation':
|
||||
employee.write({
|
||||
'user_year': employee.user_year + self.update_lines * sign,
|
||||
})
|
||||
else:
|
||||
employee.write({
|
||||
'quota_issued': employee.quota_issued + self.update_lines * sign,
|
||||
})
|
||||
|
||||
def unlink(self):
|
||||
"""删除记录时同步扣减员工加班时长"""
|
||||
@@ -162,6 +186,7 @@ class VacationOverline(models.Model):
|
||||
_description = '加班明细'
|
||||
|
||||
vacation_id = fields.Many2one('yuthon.vacation.reports', string='关联假期额度记录')
|
||||
employee_id = fields.Many2one('hr.employee', string='员工')
|
||||
workflow_record_id = fields.Many2one('soong.workflow.record', string='流程')
|
||||
update_type= fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型')
|
||||
workday = fields.Float(string='工作日')
|
||||
@@ -169,6 +194,7 @@ class VacationOverline(models.Model):
|
||||
public_holidays = fields.Float(string='公休日')
|
||||
meal_number = fields.Integer(string='误餐次数')
|
||||
update_date = fields.Date(string='更新时间')
|
||||
is_void = fields.Boolean(string='是否作废')
|
||||
text = fields.Text(string='备注')
|
||||
|
||||
def _sync_to_employee(self, reverse=False):
|
||||
@@ -208,11 +234,13 @@ class VacationMealLine(models.Model):
|
||||
_description = '误餐明细'
|
||||
|
||||
vacation_id = fields.Many2one('yuthon.vacation.reports', string='关联假期额度记录')
|
||||
employee_id = fields.Many2one('hr.employee', string='员工')
|
||||
workflow_record_id = fields.Many2one('soong.workflow.record', string='流程')
|
||||
update_type= fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型')
|
||||
update_date = fields.Date(string='更新时间')
|
||||
update_lines = fields.Float(string='更新额度')
|
||||
is_soon = fields.Boolean(string="流程修改")
|
||||
is_void = fields.Boolean(string='是否作废', default=False)
|
||||
is_manual = fields.Boolean(string="手动修改")
|
||||
text = fields.Text(string='备注')
|
||||
|
||||
|
||||
@@ -21,43 +21,49 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="假期额度记录">
|
||||
<sheet>
|
||||
<field name="employee_id"/>
|
||||
<notebook>
|
||||
<page string="年假">
|
||||
<field name="leave_ids">
|
||||
<tree editable="bottom">
|
||||
<field name="leave_ids" context="{'default_employee_id': employee_id}">
|
||||
<tree editable="bottom" delete="false">
|
||||
<field name="employee_id" column_invisible="1"/>
|
||||
<field name="vacation_id" column_invisible="1"/>
|
||||
<field name="workflow_record_id" domain="[('workflow_id.name', '=', '请假')]"/>
|
||||
<field name="update_type"/>
|
||||
<field name="update_date"/>
|
||||
<field name="workflow_record_id" domain="[('workflow_id.name', '=', '请假'), ('create_uid.employee_id', '=', employee_id)]"/>
|
||||
<field name="update_type" readonly="1"/>
|
||||
<field name="update_date" readonly="1"/>
|
||||
<field name="update_lines"/>
|
||||
<field name="allocation_type" optional="hide"/>
|
||||
<field name="text"/>
|
||||
<button name="unlink" string="删除" invisible="workflow_record_id" type="object" class="btn-primary"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="加班">
|
||||
<field name="overtime_ids">
|
||||
<field name="overtime_ids" context="{'default_employee_id': employee_id}">
|
||||
<tree editable="bottom" delete="false">
|
||||
<field name="vacation_id" column_invisible="1"/>
|
||||
<field name="workflow_record_id" domain="[('workflow_id.name', '=', '加班')]"/>
|
||||
<field name="update_type"/>
|
||||
<field name="update_date"/>
|
||||
<field name="employee_id" column_invisible="1"/>
|
||||
<field name="workflow_record_id" domain="[('workflow_id.name', '=', '加班'), ('create_uid.employee_id', '=', employee_id)]"/>
|
||||
<field name="update_type" readonly="1"/>
|
||||
<field name="update_date" readonly="1"/>
|
||||
<field name="workday"/>
|
||||
<field name="legal_day"/>
|
||||
<field name="public_holidays"/>
|
||||
<field name="meal_number" column_invisible="1"/>
|
||||
<field name="is_void"/>
|
||||
<field name="text"/>
|
||||
<button name="unlink" string="删除" invisible="workflow_record_id" type="object" class="btn-primary"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="误餐">
|
||||
<field name="meal_fee_ids">
|
||||
<field name="meal_fee_ids" context="{'default_employee_id': employee_id}">
|
||||
<tree editable="bottom" delete="false">
|
||||
<field name="employee_id" column_invisible="1"/>
|
||||
<field name="vacation_id" column_invisible="1"/>
|
||||
<field name="workflow_record_id" domain="[('workflow_id.name', '=', '外出')]"/>
|
||||
<field name="update_type"/>
|
||||
<field name="update_date"/>
|
||||
<field name="workflow_record_id" domain="[('workflow_id.name', '=', '外出'), ('create_uid.employee_id', '=', employee_id)]"/>
|
||||
<field name="update_type" readonly="1"/>
|
||||
<field name="update_date" readonly="1"/>
|
||||
<field name="update_lines"/>
|
||||
<field name="text"/>
|
||||
<button name="unlink" string="删除" invisible="workflow_record_id" type="object" class="btn-primary"/>
|
||||
@@ -94,8 +100,13 @@
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.update_log()</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="all_vacation_delete" model="ir.actions.server">
|
||||
<field name="name">清零</field>
|
||||
<field name="model_id" ref="yuthon_holiday.model_yuthon_vacation_reports"/>
|
||||
<field name="binding_model_id" ref="yuthon_holiday.model_yuthon_vacation_reports"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.vacation_delete()</field>
|
||||
</record>
|
||||
<record id="details_tree_view" model="ir.ui.view">
|
||||
<field name="name">details.tree.tree</field>
|
||||
<field name="model">details.tree</field>
|
||||
|
||||
Reference in New Issue
Block a user