Add menu to force qty on leave request
This commit is contained in:
@@ -9,6 +9,22 @@ This module adds what I consider the minimum usability level for the holiday man
|
||||
|
||||
* It sends an email to the manager when the employee submits a holiday requests (with the employee in Cc) and it sends an email to the employee (with the manager in Cc) when the holiday request is validated/refused.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
This module requires a patch on the official hr_holidays module:
|
||||
in addons/hr_holidays/hr_holidays.py, in the method holidays_validate(), remplace
|
||||
|
||||
.. code::
|
||||
|
||||
if record.holiday_type == 'employee' and record.type == 'remove':
|
||||
|
||||
by
|
||||
|
||||
.. code::
|
||||
|
||||
if record.holiday_type == 'employee' and record.type == 'remove' and record.date_from and record.date_to:
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class HrHolidays(orm.Model):
|
||||
hhpo = self.pool['hr.holidays.public']
|
||||
for hol in self.browse(cr, uid, ids, context=context):
|
||||
days = 0.0
|
||||
if hol.type == 'remove' and hol.holiday_type == 'employee':
|
||||
if hol.type == 'remove' and hol.holiday_type == 'employee' and hol.vacation_date_from and hol.vacation_date_to:
|
||||
if hol.holiday_status_id.vacation_compute_method == 'business':
|
||||
business = True
|
||||
else:
|
||||
@@ -136,13 +136,17 @@ class HrHolidays(orm.Model):
|
||||
days -= 0.5
|
||||
break
|
||||
date_dt += relativedelta(days=1)
|
||||
|
||||
if hol.type == 'remove':
|
||||
# read number_of_days_remove instead of number_of_days_temp
|
||||
res[hol.id] = {
|
||||
'number_of_days': days * -1,
|
||||
'number_of_days_remove': days,
|
||||
}
|
||||
|
||||
elif hol.type == 'remove':
|
||||
# When we do a leave and force qty
|
||||
res[hol.id] = {
|
||||
'number_of_days': hol.number_of_days_temp * -1,
|
||||
'number_of_days_remove': hol.number_of_days_temp,
|
||||
}
|
||||
else:
|
||||
# for allocations, we read the native field number_of_days_temp
|
||||
res[hol.id] = {
|
||||
@@ -231,7 +235,7 @@ class HrHolidays(orm.Model):
|
||||
def _check_vacation_dates(self, cr, uid, ids):
|
||||
hhpo = self.pool['hr.holidays.public']
|
||||
for hol in self.browse(cr, uid, ids):
|
||||
if hol.type == 'remove':
|
||||
if hol.type == 'remove' and hol.vacation_date_from and hol.vacation_date_to:
|
||||
if hol.vacation_date_from > hol.vacation_date_to:
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
|
||||
@@ -132,9 +132,65 @@ mrp.access_resource_calendar_leaves_user,only read access to manufacuting user,r
|
||||
|
||||
-->
|
||||
|
||||
<!-- When you have a balance of legal leaves of 0.1 (for example), you cannot 'use'
|
||||
it because this module only allows you to use 0.5, 1, 1.5, ...
|
||||
So, if you want to "cleanup" this balance of 0.1, you should declare a leave of 0.1
|
||||
and an allocation of 0.1 on a newer legal leave
|
||||
This menu entry is designed for this and only accessible to HR Manager -->
|
||||
|
||||
<record id="hr_holidays_leave_force_number_form" model="ir.ui.view">
|
||||
<field name="name">Leave request force qty</field>
|
||||
<field name="model">hr.holidays</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Leave Request Force Qty" version="7.0">
|
||||
<header>
|
||||
<button string="Approve" name="validate" states="confirm" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button string="Validate" name="second_validate" states="validate1" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button string="Refuse" name="refuse" states="confirm,validate,validate1" type="workflow" groups="base.group_hr_user"/>
|
||||
<button string="Reset to New" name="set_to_draft" states="cancel,refuse" type="object" groups="base.group_hr_user"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate" statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}'/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name" required="1" attrs="{'readonly':[('state','!=','draft'),('state','!=','confirm')]}"/>
|
||||
<field name="holiday_status_id" context="{'employee_id':employee_id}"/>
|
||||
<label for="number_of_days_temp" string="Leave"/>
|
||||
<div>
|
||||
<field name="number_of_days_temp" class="oe_inline"/> days
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
<field name="holiday_type" on_change="onchange_type(holiday_type)" context="{'employee_id':employee_id}" />
|
||||
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')], 'invisible':[('holiday_type','=','category')]}"/>
|
||||
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'invisible':[('holiday_type','=','employee')]}"/>
|
||||
<field name="department_id" attrs="{'invisible':[('holiday_type','=','category')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="notes" nolabel="1" colspan="4" placeholder="Add a reason..."/>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_holidays_leave_force_number_action" model="ir.actions.act_window">
|
||||
<field name="name">Leave Requests Force Qty</field>
|
||||
<field name="res_model">hr.holidays</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="hr_holidays_leave_force_number_form"/>
|
||||
<field name="context">{'default_type': 'remove'}</field>
|
||||
<field name="domain">[('type','=','remove')]</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="hr_holidays_leave_force_number_menu" action="hr_holidays_leave_force_number_action" parent="hr_holidays.menu_open_ask_holidays" sequence="15" groups="base.group_hr_manager"/>
|
||||
|
||||
<menuitem id="resource_calendar_leaves_cal_first_menu"
|
||||
action="resource_calendar_leaves_cal_first_action"
|
||||
parent="hr_holidays.menu_open_ask_holidays" sequence="100"/>
|
||||
parent="hr_holidays.menu_open_ask_holidays" sequence="50"/>
|
||||
|
||||
<record id="hr_holidays.menu_open_company_allocation" model="ir.ui.menu">
|
||||
<field name="groups_id" eval="[(4, ref('base.group_hr_user'))]"/>
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
|
||||
<menuitem id="hr_holidays_employee_counter_menu"
|
||||
action="hr_holidays_employee_counter_action"
|
||||
parent="hr_holidays.menu_open_ask_holidays"/>
|
||||
parent="hr_holidays.menu_open_ask_holidays"
|
||||
sequence="30"/>
|
||||
|
||||
|
||||
</data>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<menuitem id="hr_holidays_mass_allocation_menu"
|
||||
action="hr_holidays_mass_allocation_action"
|
||||
parent="hr_holidays.menu_open_ask_holidays"
|
||||
groups="base.group_hr_user"/>
|
||||
groups="base.group_hr_user" sequence="20"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<menuitem id="hr_holidays_post_menu"
|
||||
action="hr_holidays_post_action"
|
||||
parent="hr_holidays.menu_open_ask_holidays"
|
||||
groups="base.group_hr_user"/>
|
||||
groups="base.group_hr_user" sequence="30"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user