pengyuthon
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
'security/ir.model.access.csv',
|
||||
'views/inherit_hr_type_views.xml',
|
||||
'views/inherit_hr_leave_allocation_views.xml',
|
||||
'views/inherit_hr_leave_view.xml',
|
||||
'views/hr_leave_batch.xml',
|
||||
# 'views/inherit_hr_leave_view.xml',
|
||||
],
|
||||
'demo': [],
|
||||
'depends': ['hr_holidays'],
|
||||
|
||||
@@ -1,23 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class HrLeave(models.Model):
|
||||
_inherit = 'hr.leave'
|
||||
|
||||
leave_line_ids = fields.One2many('hr.leave.line', 'leave_id', string="假期明细")
|
||||
batch_id = fields.Many2one(string='Batch', comodel_name='hr.leave.batch', required=True, ondelete='cascade')
|
||||
|
||||
|
||||
class HrLeaveLine(models.Model):
|
||||
_name = 'hr.leave.line'
|
||||
class HolidaysRequestBatch(models.Model):
|
||||
_name = 'hr.leave.batch'
|
||||
_description = 'Time Off Batches'
|
||||
_inherit = ['mail.thread.main.attachment', 'mail.activity.mixin']
|
||||
|
||||
leave_id = fields.Many2one('hr.leave', string="关联审批")
|
||||
holiday_status_id = fields.Many2one('hr.leave.type', string="假期种类")
|
||||
days_available = fields.Float(string="可用天数", store=True)
|
||||
applicants = fields.Selection([('hour', '按小时'), ('day', '天'), ('half_day', '半天')], string="申请单位", store=True)
|
||||
date_start = fields.Datetime(string="开始时间", default=fields.Datetime.now)
|
||||
date_end = fields.Datetime(string="结束时间")
|
||||
leave_days = fields.Float(string='请假天数', store=True)
|
||||
surplus_days = fields.Float(string="剩余天数")
|
||||
leave_documents_id = fields.Many2many(related="holiday_status_id.leave_documents_id", string="假期详细说明")
|
||||
def _get_default_emp(self):
|
||||
emp = self.env['hr.employee']._get_contextual_employee()
|
||||
if not emp:
|
||||
raise
|
||||
return emp
|
||||
|
||||
name = fields.Char(string='Description')
|
||||
employee_id = fields.Many2one(string='Employee', comodel_name='hr.employee', required=True, default=_get_default_emp, index=True)
|
||||
leave_ids = fields.One2many(string='Details', comodel_name='hr.leave', inverse_name='batch_id')
|
||||
state = fields.Selection(string='State', selection=[
|
||||
('draft', 'To Submit'),
|
||||
('confirm', 'To Approve'),
|
||||
('refuse', 'Refused'),
|
||||
('validate', 'Approved')
|
||||
], default='draft', tracking=True, copy=False)
|
||||
|
||||
@api.constrains('leave_ids')
|
||||
def _check_leave_ids(self):
|
||||
for rec in self:
|
||||
if len(rec.leave_ids) < 1:
|
||||
raise ValidationError(_('You must have at least one leave request in the batch.'))
|
||||
|
||||
# 提交
|
||||
def action_submit(self):
|
||||
self.state = 'confirm'
|
||||
self.leave_ids.action_confirm()
|
||||
|
||||
# 拒绝
|
||||
def action_refuse(self):
|
||||
self.state = 'refuse'
|
||||
self.leave_ids.action_refuse()
|
||||
|
||||
# 通过
|
||||
def action_validate(self):
|
||||
self.state = 'validate'
|
||||
self.leave_ids.action_validate()
|
||||
|
||||
# 撤回
|
||||
def action_draft(self):
|
||||
self.state = 'draft'
|
||||
self.leave_ids.action_draft()
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_hr_leave_line,hr_leave_line,model_hr_leave_line,base.group_user,1,1,1,1
|
||||
access_hr_leave_batch,hr.leave.batch,model_hr_leave_batch,,1,1,1,1
|
||||
|
||||
|
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- Tree View -->
|
||||
<record id="view_hr_leave_batch_tree" model="ir.ui.view">
|
||||
<field name="name">hr.leave.batch.tree</field>
|
||||
<field name="model">hr.leave.batch</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Time Off Batches">
|
||||
<field name="employee_id"/>
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
<!-- <field name="leave_ids"/> -->
|
||||
<button name="action_validate" type="object" class="oe_highlight" string="Validate" invisible="state != 'confirm'"/>
|
||||
<button name="action_refuse" type="object" class="oe_highlight" string="Refuse" invisible="state != 'confirm'"/>
|
||||
<button name="action_draft" type="object" class="oe_highlight" string="Retract" invisible="state == 'draft' or id == False"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Form View -->
|
||||
<record id="view_hr_leave_batch_form" model="ir.ui.view">
|
||||
<field name="name">hr.leave.batch.form</field>
|
||||
<field name="model">hr.leave.batch</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<header>
|
||||
<field name="state" widget="statusbar"/>
|
||||
<button name="action_submit" type="object" class="oe_highlight" string="Submit" invisible="state != 'draft'"/>
|
||||
<button name="action_validate" type="object" class="oe_highlight" string="Validate" invisible="state != 'confirm'"/>
|
||||
<button name="action_refuse" type="object" class="oe_highlight" string="Refuse" invisible="state != 'confirm'"/>
|
||||
<button name="action_draft" type="object" class="oe_highlight" string="Retract" invisible="state == 'draft' or id == False"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="employee_id" readonly="1" forcesave="1"/>
|
||||
<field name="name"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Details">
|
||||
<field name="leave_ids" mode="tree" context="{'form_view_ref': 'hr_holidays.hr_leave_view_form_dashboard_new_time_off'}">
|
||||
<tree>
|
||||
<field name="state" column_invisible="True"/>
|
||||
<field name="holiday_type"/>
|
||||
<field name="holiday_status_id" class="fw-bold" readonly="state in ['cancel', 'refuse', 'validate', 'validate1']"/>
|
||||
<field name="name"/>
|
||||
<field name="date_from" readonly="state in ['cancel', 'refuse', 'validate', 'validate1']"/>
|
||||
<field name="date_to" readonly="state in ['cancel', 'refuse', 'validate', 'validate1']"/>
|
||||
<field name="duration_display"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" options="{'open_attachments': True}"/>
|
||||
<field name="message_ids"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Search View -->
|
||||
<record id="hr_leave_batch_search_view" model="ir.ui.view">
|
||||
<field name="model">hr.leave.batch</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Time Off Batches Search">
|
||||
<field name="name" string="Batch" filter_domain="['|',('name', 'ilike', self), ('employee_id', 'ilike', self)"/>
|
||||
<filter string="To Submit" name="filter_by_draft" domain="[('state', '=', 'draft')]"/>
|
||||
<filter string="To Approve" name="filter_by_confirm" domain="[('state', '=', 'confirm')]"/>
|
||||
<filter string="Refused" name="filter_by_refuse" domain="[('state', '=', 'refuse')]"/>
|
||||
<filter string="Approved" name="filter_by_validate" domain="[('state', '=', 'validate')]"/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter string="Employee" name="group_by_employee_id" domain="[]" context="{'group_by': 'employee_id'}"/>
|
||||
<filter string="State" name="group_by_state" domain="[]" context="{'group_by': 'state'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action My Time Off -->
|
||||
<record id="hr_leave_batch_action_my" model="ir.actions.act_window">
|
||||
<field name="name">My Time Off</field>
|
||||
<field name="res_model">hr.leave.batch</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="search_view_id" ref="hr_leave_batch_search_view"/>
|
||||
<field name="domain">[('employee_id.user_id', '=', uid)]</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="hr_holidays.hr_leave_menu_my"
|
||||
parent="hr_holidays.menu_hr_holidays_my_leaves"
|
||||
action="hr_leave_batch_action_my"
|
||||
sequence="2"
|
||||
/>
|
||||
|
||||
<!-- Action My Time Off -->
|
||||
<record id="hr_leave_batch_action_all" model="ir.actions.act_window">
|
||||
<field name="name">All Time Off</field>
|
||||
<field name="res_model">hr.leave.batch</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="search_view_id" ref="hr_leave_batch_search_view"/>
|
||||
<field name="domain">[]</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="hr_holidays.menu_open_department_leave_approve"
|
||||
parent="hr_holidays.menu_hr_holidays_management"
|
||||
action="hr_leave_batch_action_all"
|
||||
sequence="1"
|
||||
/>
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -8,9 +8,9 @@
|
||||
<xpath expr="//field[@name='display_name']" position="attributes">
|
||||
<attribute name="string">假期类型</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='display_name']" position="before">
|
||||
<field name="vacation_type_id"/>
|
||||
</xpath>
|
||||
<!-- <xpath expr="//field[@name='display_name']" position="before">-->
|
||||
<!-- <field name="vacation_type_id"/>-->
|
||||
<!-- </xpath>-->
|
||||
<xpath expr="//field[@name='allocation_validation_type']" position="attributes">
|
||||
<attribute name="column_invisible">1</attribute>
|
||||
</xpath>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
'license': 'LGPL-3',
|
||||
'author': 'pengyuthon',
|
||||
'website': 'https://www.pengyuthon.com',
|
||||
'depends': ['base', 'hr', 'hr_recruitment',],
|
||||
'depends': ['base', 'hr', 'hr_recruitment'],
|
||||
'data': [
|
||||
'data/yuthon.job.lv.csv',
|
||||
'data/employee_code_data.xml',
|
||||
|
||||
@@ -63,11 +63,11 @@
|
||||
parent="yuthon_property_menu_data"
|
||||
action="action_property_rental_form"/>
|
||||
|
||||
<menuitem id="yuthon_property_eligibility_form"
|
||||
sequence="3"
|
||||
name="承租资格申报表"
|
||||
parent="yuthon_property_menu_data"
|
||||
action="yuthon_property_approval.property_eligibility_action"/>
|
||||
<!-- <menuitem id="yuthon_property_eligibility_form"-->
|
||||
<!-- sequence="3"-->
|
||||
<!-- name="承租资格申报表"-->
|
||||
<!-- parent="yuthon_property_menu_data"-->
|
||||
<!-- action="yuthon_property_approval.property_eligibility_action"/>-->
|
||||
|
||||
<menuitem id="yuthon_property_confirmation_of_transaction_menu"
|
||||
sequence="5"
|
||||
@@ -84,11 +84,11 @@
|
||||
name="建设工程"
|
||||
parent="yuthon_property_estate_menu"
|
||||
action="property_assess_action"/>
|
||||
<menuitem id="yuthon_property_lease_contract_menu"
|
||||
sequence="3"
|
||||
name="租赁合同"
|
||||
parent="yuthon_property_estate_menu"
|
||||
action="yuthon_property_approval.property_lease_contract_action"/>
|
||||
<!-- <menuitem id="yuthon_property_lease_contract_menu"-->
|
||||
<!-- sequence="3"-->
|
||||
<!-- name="租赁合同"-->
|
||||
<!-- parent="yuthon_property_estate_menu"-->
|
||||
<!-- action="yuthon_property_approval.property_lease_contract_action"/>-->
|
||||
|
||||
<menuitem id="yuthon_property_science_menu"
|
||||
sequence="10"
|
||||
|
||||
@@ -504,11 +504,11 @@
|
||||
parent="human_work_entry_board"
|
||||
action="hr_work_entry.hr_work_entry_action"
|
||||
sequence="1"/>
|
||||
<!-- <menuitem id="human_salary_pending_leave_board"-->
|
||||
<!-- name="待报告休假"-->
|
||||
<!-- parent="human_work_entry_board"-->
|
||||
<!-- action="hr_payroll_holidays.hr_leave_work_entry_action"-->
|
||||
<!-- sequence="3"/>-->
|
||||
<menuitem id="human_salary_pending_leave_board"
|
||||
name="待报告休假"
|
||||
parent="human_work_entry_board"
|
||||
action="hr_payroll_holidays.hr_leave_work_entry_action"
|
||||
sequence="3"/>
|
||||
<menuitem id="human_pay_slips_root_board"
|
||||
name="工资条"
|
||||
parent="human_resources_salary_root_board"
|
||||
|
||||
Reference in New Issue
Block a user