Files
enterprise-addons/hr_holidays_gantt/views/hr_holidays_gantt_view.xml
T

121 lines
6.0 KiB
XML

<odoo>
<data>
<!-- Gantt view -->
<record id="hr_leave_gantt_view" model="ir.ui.view">
<field name="name">hr.leave.gantt</field>
<field name="model">hr.leave</field>
<field name="arch" type="xml">
<gantt
js_class="hr_holidays_gantt_manager_hr_leave"
date_start="date_from"
date_stop="date_to"
string="Days"
color="color"
default_group_by='employee_id'
decoration-danger="state == 'refuse'"
decoration-info="state in ['confirm', 'validate1']"
decoration-secondary="state == 'cancel'"
precision="{'week': 'day:half', 'month': 'day:half'}"
plan="0"
total_row="True"
display_unavailability="1"
>
<field name="state" invisible="1"/>
<field name="holiday_status_id" invisible="1"/>
<field name="number_of_days" invisible="1"/>
<field name="can_approve" invisible="1"/>
<field name="can_validate" invisible="1"/>
<field name="can_refuse" invisible="1"/>
<templates>
<div t-name="gantt-popover">
<t t-set="start_date_formatted" t-value="date_from.toLocaleString({ month: 'numeric', day: 'numeric', year: 'numeric' })"/>
<t t-set="stop_date_formatted" t-value="date_to.toLocaleString({ month: 'numeric', day: 'numeric', year: 'numeric' })"/>
<div>
<strong>Name: </strong><t t-out="holiday_status_id[1]"/>
</div>
<div><strong>Start: </strong> <t t-out="start_date_formatted"/></div>
<div><strong>Stop: </strong> <t t-out="stop_date_formatted"/></div>
<footer>
<button name="action_approve" class="btn btn-primary btn-sm" string="Approve" type="object"
t-if="can_approve"/>
<button name="action_approve" class="btn btn-secondary btn-sm" string="Validate" type="object"
t-if="can_validate and !can_approve"/>
<button name="action_refuse" class="btn btn-secondary btn-sm" string="Refuse" type="object"
t-if="can_refuse"/>
</footer>
</div>
</templates>
</gantt>
</field>
</record>
<record id="hr_leave_allocation_gantt_view" model="ir.ui.view">
<field name="name">hr.leave.allocation.gantt</field>
<field name="model">hr.leave.allocation</field>
<field name="arch" type="xml">
<gantt
js_class="hr_holidays_gantt_manager"
date_start="date_from"
date_stop="date_to"
string="Days"
default_group_by="employee_id"
decoration-danger="state == 'refuse'"
decoration-info="state in ['confirm']"
plan="0"
>
<field name="state" invisible="1"/>
</gantt>
</field>
</record>
<record id="hr_leave_report_calendar_view_gantt" model="ir.ui.view">
<field name="name">hr.leave.report.calendar.view.gantt</field>
<field name="model">hr.leave.report.calendar</field>
<field name="arch" type="xml">
<gantt
js_class="hr_holidays_gantt"
string="Time Off"
date_start="start_datetime"
date_stop="stop_datetime"
default_range="month"
default_group_by="employee_id"
decoration-info="state in ['confirm', 'validate1']"
decoration-danger="state == 'refused'"
color="employee_id"
total_row="True"
display_unavailability="True"
sample="1">
<field name="name"/>
<field name="state" invisible="1"/>
<field name="is_manager"/>
<templates>
<div t-name="gantt-popover">
<t t-out="start_datetime.toFormat('f ')"/>
<i class="fa fa-long-arrow-right" title="Arrow"/>
<t t-out="stop_datetime.toFormat(' f')"/>
<footer replace="0">
<button name="action_approve" class="btn btn-secondary btn-sm" string="Approve" type="object"
t-if="is_manager and ['confirm', 'refuse'].includes(state)"/>
<button name="action_approve" class="btn btn-secondary btn-sm" string="Validate" type="object"
t-if="is_manager and state == 'validate1'"/>
<button name="action_refuse" class="btn btn-secondary btn-sm" string="Refuse" type="object"
t-if="is_manager and state != 'refuse'"/>
</footer>
</div>
</templates>
</gantt>
</field>
</record>
<!-- Add gantt view mode to the hr.holidays dashboard -->
<record id="hr_holidays.action_hr_holidays_dashboard" model="ir.actions.act_window">
<field name="view_mode">gantt,calendar</field>
</record>
<record id="hr_holidays.hr_leave_action_action_approve_department" model="ir.actions.act_window">
<field name="view_mode">list,kanban,gantt,form,calendar,activity</field>
</record>
</data>
</odoo>