[REF] hr_holidays: differentiate personal and manager leave / allocation views

Purpose of this commit is to clean allocation and request views and prepare
future modifications. We would like to separate personal views (making a
request for myself) from manager views (giving more options).

Specifications

 * views under "My" menu should be simplified

  * in a general way there should be no action buttons under my. Hide
    approve/refuse buttons in personal mode;
  * show only leave type, description and duration when asking for an
    allocation; hide details about group allocation and accrual; hide
    action buttons;
  * show only leave type, description and from/to choice as well as duration
    when asking for a leave; hide details about group allocation; hide action
    buttons;
  * in list view hide employee and buttons my menu;

 * views under "Manager" menu should be complete

  * display complete form view;
  * add buttons to approve / refuse directly from the list view in manager
    menus;

This commit is linked to task ID 1876795 and PR #26571.
This commit is contained in:
Thibault Delavallée
2018-09-10 13:08:50 +02:00
parent af7901ca29
commit 2e3b392a6f
2 changed files with 211 additions and 60 deletions
@@ -47,9 +47,10 @@
</field>
</record>
<record id="edit_new_allocation" model="ir.ui.view">
<field name="name">Allocation Request</field>
<record id="hr_leave_allocation_view_form" model="ir.ui.view">
<field name="name">hr.leave.allocation.view.form</field>
<field name="model">hr.leave.allocation</field>
<field name="priority">32</field>
<field name="arch" type="xml">
<form string="Allocation Request">
<field name="can_reset" invisible="1"/>
@@ -57,18 +58,11 @@
<field name="accrual" invisible="1"/>
<header>
<button string="Confirm" name="action_confirm" states="draft" type="object" class="oe_highlight"/>
<button string="Approve" name="action_approve" states="confirm" type="object" groups="hr_holidays.group_hr_holidays_user" class="oe_highlight"
attrs="{'invisible': ['|', ('can_approve', '=', False), ('state', '!=', 'confirm')]}"/>
<button string="Validate" name="action_validate" states="validate1" type="object" groups="hr_holidays.group_hr_holidays_manager" class="oe_highlight"/>
<button string="Refuse" name="action_refuse" states="confirm,validate,validate1" type="object" groups="hr_holidays.group_hr_holidays_user"
attrs="{'invisible': ['|', ('can_approve', '=', False), ('state', 'not in', ('confirm','validate','validate1'))]}"/>
<button string="Reset to Draft" name="action_draft" type="object"
attrs="{'invisible': ['|', ('can_reset', '=', False), ('state', 'not in', ['confirm', 'refuse'])]}"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate"/>
</header>
<sheet>
<div class="oe_title">
<h1><field name="display_name"/></h1>
<h2><field name="display_name"/></h2>
</div>
<group>
<group>
@@ -77,35 +71,23 @@
<field name="holiday_status_id" context="{'employee_id':employee_id}"/>
<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)]}">
<div name="number_of_days_temp" 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)]}">
<div name="number_of_hours" 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}" />
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')],'invisible':[('holiday_type','!=','employee')]}" groups="hr_holidays.group_hr_holidays_user"/>
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'invisible':[('holiday_type','!=','category')]}"/>
<field name="department_id" groups="hr_holidays.group_hr_holidays_user" attrs="{'invisible':[('holiday_type','=','category')]}"/>
<group name="alloc_right_col">
<field name="employee_id" invisible="1" groups="hr_holidays.group_hr_holidays_user"/>
<field name="department_id" invisible="1"/>
</group>
<group attrs="{'invisible': [('accrual', '=', False)]}">
<field name="date_to" string="Run Until" help="If no value set, runs indefinitely" class="oe_inline"/>
<div class="o_row" colspan="2">
Add <field name="number_per_interval" attrs="{'required': [('accrual', '=', True)]}"/>
<field name="unit_per_interval" attrs="{'required': [('accrual', '=', True)]}"/> of leaves every
<field name="interval_number" attrs="{'required': [('accrual', '=', True)]}"/>
<field name="interval_unit" attrs="{'required': [('accrual', '=', True)]}"/>
</div>
</group>
<field name="notes" nolabel="1" colspan="4" placeholder="Add a reason..."/>
</group>
<field name="notes" nolabel="1" placeholder="Add a reason..."/>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
@@ -116,9 +98,51 @@
</field>
</record>
<record id="view_allocation_tree" model="ir.ui.view">
<field name="name">hr.leave.allocation.tree</field>
<record id="hr_leave_allocation_view_form_manager" model="ir.ui.view">
<field name="name">hr.leave.allocation.view.form.manager</field>
<field name="model">hr.leave.allocation</field>
<field name="inherit_id" ref="hr_holidays.hr_leave_allocation_view_form"/>
<field name="mode">primary</field>
<field name="priority">16</field>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_confirm']" position="after">
<button string="Approve" name="action_approve" states="confirm" type="object" groups="hr_holidays.group_hr_holidays_user" class="oe_highlight"
attrs="{'invisible': ['|', ('can_approve', '=', False), ('state', '!=', 'confirm')]}"/>
<button string="Validate" name="action_validate" states="validate1" type="object" groups="hr_holidays.group_hr_holidays_manager" class="oe_highlight"/>
<button string="Refuse" name="action_refuse" states="confirm,validate,validate1" type="object" groups="hr_holidays.group_hr_holidays_user"
attrs="{'invisible': ['|', ('can_approve', '=', False), ('state', 'not in', ('confirm','validate','validate1'))]}"/>
<button string="Reset to Draft" name="action_draft" type="object"
attrs="{'invisible': ['|', ('can_reset', '=', False), ('state', 'not in', ['confirm', 'refuse'])]}"/>
</xpath>
<xpath expr="//field[@name='employee_id']" position="before">
<field name="holiday_type" string="Mode" groups="hr_holidays.group_hr_holidays_user" context="{'employee_id':employee_id}" />
</xpath>
<xpath expr="//field[@name='employee_id']" position="replace">
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')],'invisible':[('holiday_type','!=','employee')]}"
groups="hr_holidays.group_hr_holidays_user"/>
</xpath>
<xpath expr="//field[@name='employee_id']" position="after">
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'invisible':[('holiday_type','!=','category')]}"/>
</xpath>
<xpath expr="//field[@name='department_id']" position="replace">
<field name="department_id" groups="hr_holidays.group_hr_holidays_user" attrs="{'invisible':[('holiday_type','=','category')]}"/>
</xpath>
<xpath expr="//div[@name='number_of_hours']" position="after">
<field name="date_to" string="Run Until" help="If no value set, runs indefinitely" class="oe_inline"/>
<div class="o_row" colspan="2">
Add <field name="number_per_interval" attrs="{'required': [('accrual', '=', True)]}"/>
<field name="unit_per_interval" attrs="{'required': [('accrual', '=', True)]}"/> of leaves every
<field name="interval_number" attrs="{'required': [('accrual', '=', True)]}"/>
<field name="interval_unit" attrs="{'required': [('accrual', '=', True)]}"/>
</div>
</xpath>
</field>
</record>
<record id="hr_leave_allocation_view_tree" model="ir.ui.view">
<field name="name">hr.leave.allocation.view.tree</field>
<field name="model">hr.leave.allocation</field>
<field name="priority">16</field>
<field name="arch" type="xml">
<tree decoration-danger="state == 'refuse'" decoration-info="state == 'draft'" string="Allocation Requests"
decoration-bf="message_needaction == True">
@@ -129,10 +153,44 @@
<field name="number_of_days" string="Allocated Days" sum="Total allocated days"/>
<field name="message_needaction" invisible="1"/>
<field name="state"/>
<button string="Approve" name="action_approve" type="object"
icon="fa-check text-success"
states="confirm"
groups="hr_holidays.group_hr_holidays_user"/>
<button string="Validate" name="action_validate" type="object"
icon="fa-check text-success"
states="validate1"
groups="hr_holidays.group_hr_holidays_manager"/>
<button string="Refuse" name="action_refuse" type="object"
icon="fa-ban text-danger"
states="confirm,validate,validate1"
groups="hr_holidays.group_hr_holidays_manager"/>
</tree>
</field>
</record>
<record id="hr_leave_allocation_view_tree_my" model="ir.ui.view">
<field name="name">hr.leave.allocation.view.tree.my</field>
<field name="model">hr.leave.allocation</field>
<field name="inherit_id" ref="hr_leave_allocation_view_tree"/>
<field name="mode">primary</field>
<field name="priority">32</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='employee_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_approve']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_validate']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_refuse']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
<record id="hr_leave_allocation_action_my" model="ir.actions.act_window">
<field name="name">My Allocations</field>
<field name="res_model">hr.leave.allocation</field>
@@ -145,7 +203,18 @@
</field>
<field name="context">{}</field>
<field name="domain">[('employee_id.user_id', '=', uid)]</field>
<field name="view_id" ref="edit_new_allocation"/>
</record>
<record id="hr_leave_allocation_action_my_view_tree" model="ir.actions.act_window.view">
<field name="sequence">1</field>
<field name="view_mode">tree</field>
<field name="act_window_id" ref="hr_leave_allocation_action_my"/>
<field name="view_id" ref="hr_leave_allocation_view_tree_my"/>
</record>
<record id="hr_leave_allocation_action_my_view_form" model="ir.actions.act_window.view">
<field name="sequence">2</field>
<field name="view_mode">form</field>
<field name="act_window_id" ref="hr_leave_allocation_action_my"/>
<field name="view_id" ref="hr_leave_allocation_view_form"/>
</record>
<record id="hr_leave_allocation_action_all" model="ir.actions.act_window">
@@ -153,13 +222,13 @@
<field name="res_model">hr.leave.allocation</field>
<field name="view_type">form</field>
<field name="view_mode">tree,kanban,form</field>
<field name="context">{}</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new leave allocation request
</p>
</field>
<field name="context">{}</field>
<field name="domain">[]</field>
</record>
<record id="hr_leave_allocation_action_approve_department" model="ir.actions.act_window">
+109 -27
View File
@@ -64,8 +64,8 @@
</field>
</record>
<record id="view_holiday_new_calendar" model="ir.ui.view">
<field name="name">Leave Request</field>
<record id="hr_leave_view_calendar" model="ir.ui.view">
<field name="name">hr.leave.view.calendar</field>
<field name="model">hr.leave</field>
<field name="arch" type="xml">
<calendar string="Leave Request" date_start="date_from" date_stop="date_to" mode="month" quick_add="False" color="employee_id">
@@ -74,9 +74,10 @@
</field>
</record>
<record id="edit_holiday_new_request" model="ir.ui.view">
<field name="name">Leave Request</field>
<record id="hr_leave_view_form" model="ir.ui.view">
<field name="name">hr.leave.view.form</field>
<field name="model">hr.leave</field>
<field name="priority">32</field>
<field name="arch" type="xml">
<form string="Leave Request">
<field name="can_reset" invisible="1"/>
@@ -91,8 +92,8 @@
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate"/>
</header>
<sheet>
<div class="oe_title">
<h1><field name="display_name"/></h1>
<div class="oe_title">
<h1><field name="display_name"/></h1>
</div>
<field name="leave_type_request_unit" invisible="1"/>
<group>
@@ -131,17 +132,10 @@
</div>
</div>
</group>
<group>
<field name="holiday_type" attrs="{'readonly':[('state','!=','draft')]}" string="Mode" groups="hr_holidays.group_hr_holidays_user" context="{'employee_id':employee_id}" />
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')],'invisible':[('holiday_type','!=','employee')]}" groups="hr_holidays.group_hr_holidays_user"/>
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'readonly': [('state','!=','draft'), ('state','!=','confirm')], 'invisible':[('holiday_type','!=','category')]}"/>
<field name="department_id" groups="hr_holidays.group_hr_holidays_user" attrs="{'readonly':['|',('state','=', 'validate'),('holiday_type','!=','department')],'invisible':[('holiday_type','=','category')]}"/>
<field name="payslip_status" groups="hr_holidays.group_hr_holidays_manager" widget="toggle_button"/>
<group name="col_right">
<field name="employee_id" invisible="1"/>
<field name="department_id" groups="hr_holidays.group_hr_holidays_user" invisible="1"/>
</group>
<div groups="hr_holidays.group_hr_holidays_manager">
<separator string="Comment by Manager"/>
<field name="report_note" placeholder="e.g. Report to the next month..."/>
</div>
</group>
</sheet>
<div class="oe_chatter">
@@ -153,8 +147,31 @@
</field>
</record>
<record id="view_holiday" model="ir.ui.view">
<field name="name">hr.holidays.tree</field>
<record id="hr_leave_view_form_manager" model="ir.ui.view">
<field name="name">hr.leave.view.form.manager</field>
<field name="model">hr.leave</field>
<field name="inherit_id" ref="hr_leave_view_form"/>
<field name="mode">primary</field>
<field name="priority">16</field>
<field name="arch" type="xml">
<xpath expr="//group[@name='col_right']" position="replace">
<group>
<field name="holiday_type" attrs="{'readonly':[('state','!=','draft')]}" string="Mode" groups="hr_holidays.group_hr_holidays_user" context="{'employee_id':employee_id}" />
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')],'invisible':[('holiday_type','!=','employee')]}" groups="hr_holidays.group_hr_holidays_user"/>
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'readonly': [('state','!=','draft'), ('state','!=','confirm')], 'invisible':[('holiday_type','!=','category')]}"/>
<field name="department_id" groups="hr_holidays.group_hr_holidays_user" attrs="{'readonly':['|',('state','=', 'validate'),('holiday_type','!=','department')],'invisible':[('holiday_type','=','category')]}"/>
<field name="payslip_status" groups="hr_holidays.group_hr_holidays_manager" widget="toggle_button"/>
</group>
<div groups="hr_holidays.group_hr_holidays_manager">
<separator string="Comment by Manager"/>
<field name="report_note" placeholder="e.g. Report to the next month..."/>
</div>
</xpath>
</field>
</record>
<record id="hr_leave_view_tree" model="ir.ui.view">
<field name="name">hr.holidays.view.tree</field>
<field name="model">hr.leave</field>
<field name="arch" type="xml">
<tree decoration-danger="state == 'refuse'" decoration-info="state == ' draft'" string="Leave Requests"
@@ -165,18 +182,55 @@
<field name="name"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="number_of_days" string="Number of Days" sum="Total leaves"/>
<field name="number_of_days_temp" string="Number of Days" sum="Total leaves"/>
<field name="state"/>
<field name="payslip_status" widget="toggle_button" options='{"active": "Reported in last payslips", "inactive": "To Report in Payslip"}' groups="hr_holidays.group_hr_holidays_manager"/>
<field name="category_id" invisible="1"/>
<field name="department_id" invisible="not context.get('set_visible',False)"/>
<field name="department_id" invisible="1"/>
<field name="manager_id" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="message_needaction" invisible="1"/>
<button string="Approve" name="action_approve" type="object"
icon="fa-check text-success"
states="confirm"
groups="hr_holidays.group_hr_holidays_user"/>
<button string="Validate" name="action_validate" type="object"
icon="fa-check text-success"
states="validate1"
groups="hr_holidays.group_hr_holidays_manager"/>
<button string="Refuse" name="action_refuse" type="object"
icon="fa-ban text-danger"
states="confirm,validate,validate1"
groups="hr_holidays.group_hr_holidays_manager"/>
</tree>
</field>
</record>
<record id="hr_leave_view_tree_my" model="ir.ui.view">
<field name="name">hr.holidays.view.tree</field>
<field name="model">hr.leave</field>
<field name="inherit_id" ref="hr_leave_view_tree"/>
<field name="mode">primary</field>
<field name="priority">32</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='employee_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='payslip_status']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_approve']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_validate']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_refuse']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
<record id="action_hr_holidays_dashboard" model="ir.actions.act_window">
<field name="name">All Leaves</field>
<field name="res_model">hr.leave</field>
@@ -245,10 +299,8 @@
<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" eval="False"/>
<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
@@ -260,6 +312,24 @@
</p>
</field>
</record>
<record id="hr_leave_action_new_request_view_calendar" model="ir.actions.act_window.view">
<field name="sequence">1</field>
<field name="view_mode">calendar</field>
<field name="act_window_id" ref="hr_leave_action_new_request"/>
<field name="view_id" ref="hr_leave_view_calendar"/>
</record>
<record id="hr_leave_action_new_request_view_tree" model="ir.actions.act_window.view">
<field name="sequence">2</field>
<field name="view_mode">tree</field>
<field name="act_window_id" ref="hr_leave_action_new_request"/>
<field name="view_id" ref="hr_leave_view_tree_my"/>
</record>
<record id="hhr_leave_action_new_request_view_form" model="ir.actions.act_window.view">
<field name="sequence">3</field>
<field name="view_mode">form</field>
<field name="act_window_id" ref="hr_leave_action_new_request"/>
<field name="view_id" ref="hr_leave_view_form"/>
</record>
<menuitem
id="hr_leave_menu_new_request"
@@ -269,9 +339,10 @@
<record id="hr_leave_action_my" model="ir.actions.act_window">
<field name="name">Leaves Requests</field>
<field name="type">ir.actions.act_window</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_mode">tree,form,calendar,kanban</field>
<field name="context">{}</field>
<field name="domain">[('user_id', '=', uid)]</field>
<field name="help" type="html">
@@ -285,6 +356,18 @@
</p>
</field>
</record>
<record id="hr_leave_action_my_view_tree" model="ir.actions.act_window.view">
<field name="sequence">1</field>
<field name="view_mode">tree</field>
<field name="act_window_id" ref="hr_leave_action_my"/>
<field name="view_id" ref="hr_leave_view_tree_my"/>
</record>
<record id="hr_leave_action_my_view_form" model="ir.actions.act_window.view">
<field name="sequence">2</field>
<field name="view_mode">form</field>
<field name="act_window_id" ref="hr_leave_action_my"/>
<field name="view_id" ref="hr_leave_view_form"/>
</record>
<menuitem
id="hr_leave_menu_my"
@@ -294,6 +377,7 @@
<record id="hr_leave_action_all" model="ir.actions.act_window">
<field name="name">Leaves</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.leave</field>
<field name="view_type">form</field>
<field name="view_mode">tree,kanban,form,calendar</field>
@@ -310,7 +394,7 @@
<field name="name">Department Leaves</field>
<field name="res_model">hr.leave</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,kanban</field>
<field name="view_mode">tree,kanban,form,calendar</field>
<field name="context">{
'search_default_department':1,
'search_default_approve':1}
@@ -354,7 +438,7 @@
<field name="name">Leaves Requests</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_mode">tree,kanban,form,calendar</field>
<field name="context">{'search_default_gray': True}</field>
<field name="domain">[]</field>
<field name="help" type="html">
@@ -407,9 +491,7 @@
<field name="res_model">hr.leave</field>
<field name="view_type">form</field>
<field name="view_mode">graph,pivot,calendar,form</field>
<field name="view_id"></field> <!-- force empty -->
<field name="context">{'search_default_leaves':1}</field>
<field name="search_view_id" ref="view_hr_holidays_filter"/>
</record>
<record id="action_window_leave_graph" model="ir.actions.act_window.view">