[IMP] hr_holidays: improve views

- Hide transition mode if there is 0 or 1 level on accrual plan;
- Fix kanban card
- Reduce bottom padding on calendar view
- Log a message when an allocation linked to accrual runs for the first
time

closes odoo/odoo#75940

Taskid: 2636417
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Kevin Baptiste
2021-09-08 12:44:49 +00:00
parent 09bd19d8b5
commit 8c969fb980
9 changed files with 69 additions and 23 deletions
@@ -17,6 +17,33 @@
<field name="responsible_id" ref="base.user_admin"/>
</record>
<!-- Accrual Plan -->
<record id="hr_accrual_plan_1" model="hr.leave.accrual.plan">
<field name="name">Seniority Plan</field>
</record>
<record id="hr_accrual_level_1" model="hr.leave.accrual.level">
<field name="accrual_plan_id" ref="hr_accrual_plan_1" />
<field name="start_count">1</field>
<field name="start_type">day</field>
<field name="added_value">1</field>
<field name="frequency">yearly</field>
</record>
<record id="hr_accrual_level_2" model="hr.leave.accrual.level">
<field name="accrual_plan_id" ref="hr_accrual_plan_1" />
<field name="start_count">4</field>
<field name="start_type">year</field>
<field name="added_value">2</field>
<field name="frequency">yearly</field>
</record>
<record id="hr_accrual_level_3" model="hr.leave.accrual.level">
<field name="accrual_plan_id" ref="hr_accrual_plan_1" />
<field name="start_count">8</field>
<field name="start_type">year</field>
<field name="added_value">3</field>
<field name="frequency">yearly</field>
</record>
<!-- ++++++++++++++++++++++ Mitchell Admin ++++++++++++++++++++++ -->
<record id="hr_holidays_allocation_cl" model="hr.leave.allocation">
@@ -19,6 +19,12 @@ class AccrualPlan(models.Model):
string="Level Transition", default="immediately", required=True,
help="""Immediately: When the date corresponds to the new level, your accrual is automatically computed, granted and you switch to new level
After this accrual's period: When the accrual is complete (a week, a month), and granted, you switch to next level if allocation date corresponds""")
show_transition_mode = fields.Boolean(compute='_compute_show_transition_mode')
@api.depends('level_ids')
def _compute_show_transition_mode(self):
for plan in self:
plan.show_transition_mode = len(plan.level_ids) > 1
@api.depends('allocation_ids')
def _compute_employee_count(self):
@@ -83,7 +83,7 @@ class AccrualPlanLevel(models.Model):
second_month_day = fields.Integer(default=1)
second_month = fields.Selection([
('jul', 'July'),
('aug', 'Augustus'),
('aug', 'August'),
('sep', 'September'),
('oct', 'October'),
('nov', 'November'),
@@ -97,7 +97,7 @@ class AccrualPlanLevel(models.Model):
('may', 'May'),
('jun', 'June'),
('jul', 'July'),
('aug', 'Augustus'),
('aug', 'August'),
('sep', 'September'),
('oct', 'October'),
('nov', 'November'),
@@ -380,6 +380,7 @@ class HolidaysAllocation(models.Model):
The goal of this method is to retroactively apply accrual plan levels and progress from nextcall to today
"""
today = fields.Date.today()
first_allocation = _("""This allocation have already ran once, any modification won't be effective to the days allocated to the employee. If you need to change the configuration of the allocation, cancel and create a new one.""")
for allocation in self:
level_ids = self.accrual_plan_id.level_ids.sorted('sequence')
if not level_ids:
@@ -392,6 +393,7 @@ class HolidaysAllocation(models.Model):
continue
allocation.lastcall = max(allocation.lastcall, first_level_start_date)
allocation.nextcall = first_level._get_next_date(allocation.lastcall)
allocation._message_log(body=first_allocation)
days_added_per_level = defaultdict(lambda: 0)
while allocation.nextcall <= today:
current_level = allocation._get_current_accrual_plan_level_id(allocation.nextcall)
@@ -5,8 +5,8 @@
<field name="model">hr.leave.employee.type.report</field>
<field name="arch" type="xml">
<search string="Search Time Off">
<field name="date_from"/>
<field name="employee_id"/>
<field name="date_from"/>
<filter name="year" date="date_from" default_period="this_year" string="Period"/>
<filter string="Company" name="company" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
<filter string="Employee" name="employee" context="{'group_by':'employee_id'}"/>
@@ -6,6 +6,7 @@
<field name="model">hr.leave.report</field>
<field name="arch" type="xml">
<search string="Search Time Off">
<field name="employee_id"/>
<field name="name"/>
<filter domain="[('state','in',('confirm','validate1'))]" string="To Approve" name="approve"/>
<filter string="Approved Requests" domain="[('state', '=', 'validate')]" name="validated"/>
@@ -22,7 +23,6 @@
<separator/>
<filter string="My Requests" name="my_leaves" domain="[('employee_id.user_id', '=', uid)]"/>
<separator/>
<field name="employee_id"/>
<field name="department_id" operator="child_of"/>
<field name="holiday_status_id"/>
<group expand="0" string="Group By">
@@ -2,11 +2,10 @@
.o_timeoff_container {
height: auto;
box-shadow: inset 0 -1px 0 $border-color;
}
.o_calendar_container {
height: auto;
position: sticky;
top: 0;
z-index: 100;
background-color: $o-webclient-background-color;
}
.o_timeoff_card {
@@ -28,6 +27,13 @@
background-color: unset;
}
}
.fc-content-skeleton {
padding: 0;
tbody {
display: none;
}
}
}
}
}
@@ -28,8 +28,8 @@
<field name="frequency"/>
<div class="o_row">
<label for="week_day" string="on" attrs="{'invisible': [('frequency', '!=', 'weekly')]}"/><field name="week_day" attrs="{'invisible': [('frequency', '!=', 'weekly')]}"/>
<label for="first_day" string="on the" attrs="{'invisible': [('frequency', '!=', 'monthly')]}"/><field name="first_day" attrs="{'invisible': [('frequency', '!=', 'monthly')]}"/>
<label for="first_day" string="on the" attrs="{'invisible': [('frequency', '!=', 'bimonthly')]}"/><field name="first_day" attrs="{'invisible': [('frequency', '!=', 'bimonthly')]}"/><span attrs="{'invisible': [('frequency', '!=', 'bimonthly')]}">and on the</span><field name="second_day" attrs="{'invisible': [('frequency', '!=', 'bimonthly')]}"/>
<label for="first_day" string="on the" attrs="{'invisible': [('frequency', '!=', 'monthly')]}"/><field name="first_day" attrs="{'invisible': [('frequency', '!=', 'monthly')]}"/><span attrs="{'invisible': [('frequency', '!=', 'monthly')]}">day of the month</span>
<label for="first_day" string="on the" attrs="{'invisible': [('frequency', '!=', 'bimonthly')]}"/><field name="first_day" attrs="{'invisible': [('frequency', '!=', 'bimonthly')]}"/><span attrs="{'invisible': [('frequency', '!=', 'bimonthly')]}">and on the</span><field name="second_day" attrs="{'invisible': [('frequency', '!=', 'bimonthly')]}"/><span attrs="{'invisible': [('frequency', '!=', 'bimonthly')]}">days of the month</span>
<label for="first_month_day" string="on the" attrs="{'invisible': [('frequency', '!=', 'biyearly')]}"/><field name="first_month_day" attrs="{'invisible': [('frequency', '!=', 'biyearly')]}"/><field name="first_month" attrs="{'invisible': [('frequency', '!=', 'biyearly')]}"/><span attrs="{'invisible': [('frequency', '!=', 'biyearly')]}">and on the</span><field name="second_month_day" attrs="{'invisible': [('frequency', '!=', 'biyearly')]}"/><field name="second_month" attrs="{'invisible': [('frequency', '!=', 'biyearly')]}"/>
<label for="yearly_day" string="on" attrs="{'invisible': [('frequency', '!=', 'yearly')]}"/><field name="yearly_day" attrs="{'invisible': [('frequency', '!=', 'yearly')]}"/><field name="yearly_month" attrs="{'invisible': [('frequency', '!=', 'yearly')]}"/>
</div>
@@ -63,6 +63,7 @@
<field name="model">hr.leave.accrual.plan</field>
<field name="arch" type="xml">
<form string="Accrual Plan">
<field name="show_transition_mode" invisible="1" />
<sheet>
<div class="oe_button_box" name="button_box" attrs="{'invisible': [('id', '=', False)]}">
<button name="action_open_accrual_plan_employees" type="object" class="oe_stat_button" icon="fa-users">
@@ -77,7 +78,7 @@
<field name="time_off_type_id"/>
</group>
<group>
<field name="transition_mode" widget="radio"/>
<field name="transition_mode" widget="radio" attrs="{'invisible': [('show_transition_mode', '=', False)]}"/>
</group>
</group>
<span class="oe_grey" invisible="1">
@@ -114,6 +115,7 @@
<field name="yearly_month"/>
<field name="maximum_leave"/>
<field name="action_with_unused_accruals"/>
<field name="is_based_on_worked_time"/>
<templates>
<div t-name="kanban-box">
<div class="o_hr_holidays_body oe_kanban_global_click">
@@ -143,17 +145,23 @@
</div>
<div>
Adds <field name="added_value"/> <field name="added_value_type"/>
<t t-if="record.is_based_on_worked_time.raw_value">(based on worked time)</t>
</div>
<div>
<field name="frequency"/>
<t t-if="record.frequency.value == 'weekly'">
<t t-if="record.frequency.raw_value == 'weekly'">
on <field name="week_day"/>
</t>
<t t-elif="record.frequency.value === 'bimonthly'">
on the <field name="first_day"/> and on the <field name="second_day"/>
<t t-elif="record.frequency.raw_value === 'monthly'">
on the <field name="first_day"/> day of the month
</t>
<t t-elif="record.frequency.value === 'biyearly'">
<t t-elif="record.frequency.raw_value === 'bimonthly'">
on the <field name="first_day"/> and on the <field name="second_day"/> days of the months
</t>
<t t-elif="record.frequency.raw_value === 'biyearly'">
on the <field name="first_month_day"/> <field name="first_month"/> and on the <field name="second_month_day"/> <field name="second_month"/>
</t>
<t t-elif="record.frequency.value === 'yearly'">
<t t-elif="record.frequency.raw_value === 'yearly'">
on <field name="yearly_day"/> <field name="yearly_month"/>
</t>
</div>
+3 -6
View File
@@ -130,18 +130,15 @@
</div>
</div>
</div>
<div class="row no-gutters" t-if="['validate', 'refuse'].includes(record.state.raw_value)">
<div class="row no-gutters">
<div class="col-3"/>
<div class="col-9">
<div class="col-6" t-if="['validate', 'refuse'].includes(record.state.raw_value)">
<span t-if="record.state.raw_value === 'validate'" class="fa fa-check text-muted" aria-label="validated"/>
<span t-else="" class="fa fa-ban text-muted" aria-label="refused"/>
<t t-set="classname" t-value="{'validate': 'badge-success', 'refuse': 'badge-danger'}[record.state.raw_value] || 'badge-light'"/>
<span t-attf-class="badge badge-pill {{ classname }}"><t t-esc="record.state.value"/></span>
</div>
</div>
<div class="row no-gutters" t-if="record.can_approve.raw_value">
<div class="col-3"/>
<div class="col=6" t-if="['confirm', 'validate1'].includes(record.state.raw_value)">
<div class="col-6" t-if="['confirm', 'validate1'].includes(record.state.raw_value)">
<button t-if="record.state.raw_value === 'confirm'" name="action_approve" type="object" class="btn btn-link btn-sm pl-0">
<i class="fa fa-thumbs-up"/> Approve
</button>