Merge pull request !9324 from 李鹏宇/dev
This commit is contained in:
@@ -85,6 +85,7 @@
|
||||
'wizard/yuthon_run_wizard.xml',
|
||||
'wizard/applet_security_quick_perm_views.xml',
|
||||
'wizard/export_date_wizard_views.xml',
|
||||
'wizard/overtime_change_wizard_views.xml',
|
||||
'report/overtime_approval_report.xml',
|
||||
'report/overtime_approval_templates.xml',
|
||||
],
|
||||
|
||||
@@ -1439,6 +1439,21 @@ class YuthonVacationReports(models.Model):
|
||||
record.overtime_public_holidays_total = public_holidays_total
|
||||
record.overtime_grand_total = workday_total + legal_day_total + public_holidays_total
|
||||
|
||||
def action_overtime_change(self):
|
||||
"""打开加班变更向导"""
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': '加班变更',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'overtime.change.wizard',
|
||||
'view_mode': 'form',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'active_model': 'yuthon.vacation.reports',
|
||||
'active_id': self.id,
|
||||
},
|
||||
}
|
||||
|
||||
@api.depends('meal_fee_ids.update_lines', 'meal_fee_ids.update_type', 'meal_fee_ids.is_void')
|
||||
def _compute_meal_fee(self):
|
||||
for record in self:
|
||||
|
||||
@@ -94,4 +94,5 @@ access_yuthon_overtime_line,yuthon.overtime.line,model_yuthon_overtime_line,base
|
||||
access_overtime_active_line,overtime.active.line,model_overtime_active_line,base.group_user,1,1,1,1
|
||||
access_export_date_wizard,export.date.wizard,model_export_date_wizard,base.group_user,1,1,1,1
|
||||
access_vacation_meal_active,vacation.meal.active,model_vacation_meal_active,base.group_user,1,1,1,1
|
||||
access_yuthon_vacation_import_wizard,yuthon.vacation.import.wizard,model_yuthon_vacation_import_wizard,base.group_user,1,1,1,1
|
||||
access_yuthon_vacation_import_wizard,yuthon.vacation.import.wizard,model_yuthon_vacation_import_wizard,base.group_user,1,1,1,1
|
||||
access_overtime_change_wizard,overtime.change.wizard,model_overtime_change_wizard,base.group_user,1,1,1,1
|
||||
|
@@ -250,6 +250,7 @@
|
||||
</page>
|
||||
<page string="加班">
|
||||
<button name="overtime_allocation" string="分配" type="object" class="btn btn-primary"/>
|
||||
<button name="action_overtime_change" string="变更" type="object" class="btn btn-secondary"/>
|
||||
<group col="4">
|
||||
<group>
|
||||
<field name="overtime_workday_total" readonly="1"/>
|
||||
|
||||
@@ -12,3 +12,4 @@ from . import yuthon_run_wizard
|
||||
from . import applet_security_quick_perm_wizard
|
||||
from . import export_date_wizard
|
||||
from . import yuthon_vacation_import_wizard
|
||||
from . import overtime_change_wizard
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class OvertimeChangeWizard(models.TransientModel):
|
||||
_name = 'overtime.change.wizard'
|
||||
_description = '加班变更向导'
|
||||
|
||||
vacation_id = fields.Many2one('yuthon.vacation.reports', string='假期额度记录', required=True)
|
||||
employee_id = fields.Many2one('hr.employee', string='员工', related='vacation_id.employee_id', readonly=True)
|
||||
|
||||
# 加班明细行字段
|
||||
update_type = fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型', required=True, default='add')
|
||||
update_date = fields.Date(string='更新时间', default=fields.Date.today)
|
||||
workday = fields.Float(string='工作日h', digits=(16, 1), default=0.0)
|
||||
legal_day = fields.Float(string='法定节假日h', digits=(16, 1), default=0.0)
|
||||
public_holidays = fields.Float(string='公休日h', digits=(16, 1), default=0.0)
|
||||
valid_date = fields.Date(string='有效期至')
|
||||
adjust_date = fields.Date(string='调整至')
|
||||
overtime_methods = fields.Selection([('leave', '补休'), ('fee', '加班费结算')], string='加班补偿方式', default='leave')
|
||||
text = fields.Text(string='备注')
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super(OvertimeChangeWizard, self).default_get(fields_list)
|
||||
# 从上下文获取vacation_id
|
||||
if self._context.get('active_model') == 'yuthon.vacation.reports' and self._context.get('active_id'):
|
||||
res['vacation_id'] = self._context.get('active_id')
|
||||
return res
|
||||
|
||||
def action_confirm(self):
|
||||
"""确认按钮:创建加班明细行"""
|
||||
self.ensure_one()
|
||||
if not self.vacation_id:
|
||||
raise ValidationError(_('未找到假期额度记录'))
|
||||
|
||||
# 创建加班明细行
|
||||
vals = {
|
||||
'vacation_id': self.vacation_id.id,
|
||||
'update_type': self.update_type,
|
||||
'update_date': self.update_date,
|
||||
'workday': self.workday,
|
||||
'legal_day': self.legal_day,
|
||||
'public_holidays': self.public_holidays,
|
||||
'valid_date': self.valid_date,
|
||||
'adjust_date': self.adjust_date,
|
||||
'overtime_methods': self.overtime_methods,
|
||||
'text': self.text,
|
||||
}
|
||||
|
||||
self.env['vacation.over.line'].create(vals)
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- 加班变更向导 Form 视图 -->
|
||||
<record id="view_overtime_change_wizard_form" model="ir.ui.view">
|
||||
<field name="name">overtime.change.wizard.form</field>
|
||||
<field name="model">overtime.change.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="加班变更">
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="employee_id" readonly="1"/>
|
||||
<field name="update_type"/>
|
||||
<field name="update_date"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="workday"/>
|
||||
<field name="legal_day"/>
|
||||
<field name="public_holidays"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group>
|
||||
<field name="valid_date"/>
|
||||
<field name="adjust_date"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="overtime_methods"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name="text"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button name="action_confirm" string="确认" type="object" class="btn-primary"/>
|
||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 加班变更向导 Action -->
|
||||
<record id="action_overtime_change_wizard" model="ir.actions.act_window">
|
||||
<field name="name">加班变更</field>
|
||||
<field name="res_model">overtime.change.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user