Merge pull request !3033 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-06-02 13:25:52 +00:00
committed by Gitee
6 changed files with 80 additions and 14 deletions
@@ -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})
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})
@@ -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
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,
})
@@ -62,11 +62,11 @@
<field name="state">code</field>
<field name="code">action = model.action_uninstall_wizard()</field>
</record>
<record id="all_allocation_date_uninstall" model="ir.actions.server">
<field name="name">初始化时间</field>
<record id="all_update_employee" model="ir.actions.server">
<field name="name">一次性更新</field>
<field name="model_id" ref="hr_holidays.model_hr_leave_allocation"/>
<field name="binding_model_id" ref="hr_holidays.model_hr_leave_allocation"/>
<field name="state">code</field>
<field name="code">action = model.allocation_date()</field>
<field name="code">action = model.update_employee()</field>
</record>
</odoo>
@@ -5,10 +5,11 @@
<field name="model">yuthon.vacation.reports</field>
<field name="arch" type="xml">
<tree string="假期报表" editable="bottom">
<field name="employee_id"/>
<field name="employee_id" options="{'no_create': True}"/>
<field name="leave"/>
<field name="working_overtime"/>
<field name="meal_fee"/>
<field name="company_id" optional="hide"/>
<button name="vacation_details" string="详情" type="object" class="oe_highlight"/>
<button name="button_fixes_approval" string="修正" type="object" class="oe_highlight"/>
</tree>
@@ -19,5 +20,12 @@
<field name="res_model">yuthon.vacation.reports</field>
<field name="view_mode">tree</field>
</record>
<record id="all_update_employee" 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.update_vacation()</field>
</record>
</odoo>
@@ -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'
@@ -11,7 +11,7 @@
<xpath expr="//field[@name='company_id']" position="after">
<field name="document_ids" widget="preview_many2many"/>
<button type="object" name="Fileline" string="归档明细" class="oe_highlight"/>
<button type="object" name="add_comment" string="确认" class="oe_highlight"/>
<button type="object" name="add_comment" string="完成" class="oe_highlight"/>
</xpath>
</field>
</record>