[MERGE][IMP] hr_holidays: improve and fix views

According to tasks purpose: clean leave view

See sub commits for more details.

This commit is linked to task ID 1871812 and closes PR #26180.
This commit is contained in:
Thibault Delavallée
2018-08-08 16:33:02 +02:00
4 changed files with 91 additions and 25 deletions
+8 -8
View File
@@ -41,7 +41,7 @@ class HolidaysType(models.Model):
('wheat', 'Wheat'),
('ivory', 'Ivory')], string='Color in Report', required=True, default='red',
help='This color will be used in the leaves summary located in Reporting > Leaves by Department.')
limit = fields.Boolean('Unlimited',
limit = fields.Boolean('Exceed Allocation',
help="If you select this check box, the system will allow the employees to ask"
"for leaves without allocating some beforehand")
active = fields.Boolean('Active', default=True,
@@ -58,16 +58,16 @@ class HolidaysType(models.Model):
company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.user.company_id)
validation_type = fields.Selection([('hr', 'Human Resource Responsible'),
('manager', 'Manager'),
validation_type = fields.Selection([('hr', 'Human Resource officer'),
('manager', 'Employee Manager'),
('both', 'Double Validation')],
default='hr',
string='Validation By')
employee_applicability = fields.Selection([('both', 'On Leave As Well As On Allocation'),
('leave', 'Only On Leave'),
('allocation', 'Only On Allocation')],
default=lambda self: 'leave' if self.limit else 'both', string='Available For Employee :',
employee_applicability = fields.Selection([('both', 'Both'),
('leave', 'Can be requested'),
('allocation', 'Can be allocated')],
default=lambda self: 'leave' if self.limit else 'both', string='Mode',
help='This leave type will be available on Leave / Allocation request based on selected value')
validity_start = fields.Date("Start Date", default=fields.Date.today,
@@ -84,7 +84,7 @@ class HolidaysType(models.Model):
('half', 'Half-day'),
('hour', 'Hours')], default='day', string='Take Leaves in', required=True)
accrual = fields.Boolean('Is Accrual', default=False,
accrual = fields.Boolean('Accrual', default=False,
help='This option forces this type of leave to be allocated accrually')
unpaid = fields.Boolean('Is Unpaid', default=False)
@@ -75,8 +75,18 @@
<field name="type_request_unit" invisible="1"/>
<field name="name" attrs="{'readonly':[('state','!=','draft'),('state','!=','confirm')]}"/>
<field name="holiday_status_id" context="{'employee_id':employee_id}"/>
<field name="number_of_days_temp" string="Duration" attrs="{'readonly': [('state', '=', 'validate')], 'invisible': ['|', ('type_request_unit', '=', 'hour'),('accrual', '=', True)]}"/>
<field name="number_of_hours" string="Duration" attrs="{'readonly': [('state', '=', 'validate')], 'invisible': ['|', ('type_request_unit', '!=', 'hour'),('accrual', '=', True)]}"/>
<label for="number_of_days_temp" string="Duration" attrs="{'readonly': [('state', '=', 'validate')], 'invisible': ['|', ('type_request_unit', '=', 'hour'),('accrual', '=', True)]}"/>
<div attrs="{'readonly': [('state', '=', 'validate')], 'invisible': ['|', ('type_request_unit', '=', 'hour'),('accrual', '=', True)]}">
<field name="number_of_days_temp" class="oe_inline" nolabel="1" string="Duration"/>
<span class="ml8">Days</span>
</div>
<label for="number_of_hours" string="Duration" attrs="{'readonly': [('state', '=', 'validate')], 'invisible': ['|', ('type_request_unit', '!=', 'hour'),('accrual', '=', True)]}"/>
<div attrs="{'readonly': [('state', '=', 'validate')], 'invisible': ['|', ('type_request_unit', '!=', 'hour'),('accrual', '=', True)]}">
<field name="number_of_hours" class="oe_inline" nolabel="1" string="Duration"/>
<span class="ml8">Hours</span>
</div>
</group>
<group>
<field name="holiday_type" string="Mode" groups="hr_holidays.group_hr_holidays_user" context="{'employee_id':employee_id}" />
@@ -34,25 +34,25 @@
<field name="sequence" attrs="{'invisible': [('limit', '!=', False)]}" groups="base.group_no_one"/>
<field name="time_type" groups="base.group_no_one"/>
</group>
<group name="allocation_request" string="Allocation" attrs="{'invisible': [('unpaid', '=', True)]}">
<field name="accrual"/>
<field name="negative" attrs="{'invisible': [('accrual', '=', False)]}"/>
<field name="balance_limit" attrs="{'invisible': [('accrual', '=', False)]}"/>
</group>
<group name="validation" string="Validation">
<field name="validation_type" widget="radio"/>
</group>
<group name="visibility" string="Visibility">
<field name="employee_applicability" widget="radio" attrs="{'readonly': ['|', ('limit', '=', True), ('accrual', '=', True)]}" force_save="1"/>
</group>
<group name="calendar" string="Calendar">
<group name="validity" string="Validity" attrs="{'invisible': [('employee_applicability', '=', 'allocation')]}">
<field name="validity_start"/>
<field name="validity_stop"/>
</group>
<group name="calendar" string="Calendar" groups="base.group_no_one">
<field name="categ_id"/>
<field name="color_name"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<group name="validity" string="Validity" attrs="{'invisible': [('employee_applicability', '=', 'allocation')]}">
<field name="validity_start"/>
<field name="validity_stop"/>
<group name="allocation_request" string="Allocation Type" attrs="{'invisible': [('unpaid', '=', True)]}">
<field name="accrual"/>
<field name="negative" attrs="{'invisible': [('accrual', '=', False)]}"/>
<field name="balance_limit" attrs="{'invisible': [('accrual', '=', False)]}"/>
</group>
</group>
</sheet>
@@ -143,6 +143,7 @@
action="open_view_holiday_status"
name="Leave Types"
parent="menu_hr_holidays_configuration"
groups="hr_holidays.group_hr_holidays_user"
sequence="1"/>
</odoo>
+61 -6
View File
@@ -103,9 +103,16 @@
<field name="name" attrs="{'readonly':[('state','!=','draft'),('state','!=','confirm')]}"/>
<field name="holiday_status_id" context="{'employee_id':employee_id, 'default_date_from':date_from}"/>
<field name="number_of_days_temp" attrs="{'invisible': [('leave_type_request_unit', '=', 'hour')]}"/>
<field name="number_of_hours" attrs="{'invisible': [('leave_type_request_unit', '!=', 'hour')]}"/>
<label for="number_of_days_temp" string="Duration"/>
<div>
<div attrs="{'invisible': [('leave_type_request_unit', '=', 'hour')]}">
<field name="number_of_days_temp" nolabel="1" class="oe_inline"/>
<span class="ml8">Days</span>
</div>
<div attrs="{'invisible': [('leave_type_request_unit', '!=', 'hour')]}">
<field name="number_of_hours" nolabel="1" class="oe_inline"/>
<span class="ml8">Hours</span>
</div>
<field name="request_unit_all" widget="radio" attrs="{'readonly': [('state', '=', 'validate')], 'invisible': [('leave_type_request_unit', '=', 'day')]}"/>
<field name="request_unit_day" widget="radio" attrs="{'readonly': [('state', '=', 'validate')], 'invisible': [('leave_type_request_unit', '!=', 'day')]}"/>
@@ -202,13 +209,13 @@
id="menu_hr_holidays_my_leaves"
name="My Leaves"
parent="menu_hr_holidays_root"
sequence="2"/>
sequence="3"/>
<menuitem
id="menu_hr_holidays_approvals"
name="Managers"
parent="menu_hr_holidays_root"
sequence="3"
sequence="4"
groups="hr_holidays.group_hr_holidays_manager,hr_holidays.group_hr_holidays_user"/>
<menuitem
@@ -219,9 +226,10 @@
groups="hr_holidays.group_hr_holidays_manager,hr_holidays.group_hr_holidays_user"/>
<record id="open_ask_holidays" model="ir.actions.act_window">
<field name="name">Leaves Request</field>
<field name="name">New Request</field>
<field name="res_model">hr.leave</field>
<field name="view_type">form</field>
<field name="view_mode">calendar,tree,form</field>
<field name="view_id" ref="edit_holiday_new_request"/>
<field name="context">{}</field>
<field name="domain">[('user_id', '=', uid)]</field>
@@ -259,10 +267,57 @@
<field name="act_window_id" ref="open_ask_holidays"/>
</record>
<record id="hr_leave_action_my_tree" model="ir.actions.act_window">
<field name="name">Leaves Request</field>
<field name="res_model">hr.leave</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar,form</field>
<field name="view_id" ref="edit_holiday_new_request"/>
<field name="context">{}</field>
<field name="domain">[('user_id', '=', uid)]</field>
<field name="search_view_id" ref="view_hr_holidays_filter"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new leave request
</p><p>
Once you have recorded your leave request, it will be sent
to a manager for validation. Be sure to set the right leave
type (recuperation, legal leaves, sickness) and the exact
number of open days related to your leave.
</p>
</field>
</record>
<menuitem
id="menu_open_ask_holidays_new"
parent="menu_hr_holidays_my_leaves"
parent="menu_hr_holidays_root"
action="open_ask_holidays"
sequence="2"/>
<record id="hr_leave_action_view_my_tree_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_holiday"/>
<field name="act_window_id" ref="hr_leave_action_my_tree"/>
</record>
<record id="hr_leave_action_view_my_tree_form" model="ir.actions.act_window.view">
<field name="sequence" eval="20"/>
<field name="view_mode">form</field>
<field name="view_id" ref="edit_holiday_new_request"/>
<field name="act_window_id" ref="hr_leave_action_my_tree"/>
</record>
<record id="hr_leave_action_view_my_tree_calendar" model="ir.actions.act_window.view">
<field name="sequence" eval="10"/>
<field name="view_mode">calendar</field>
<field name="view_id" ref="view_holiday_new_calendar"/>
<field name="act_window_id" ref="hr_leave_action_my_tree"/>
</record>
<menuitem
id="hr_leave_menu_my"
parent="menu_hr_holidays_my_leaves"
action="hr_leave_action_my_tree"
sequence="22"/>
<record id="open_employee_leaves" model="ir.actions.act_window">