[ADD] hr_homeworking: add homeworking information and features for employees

task-2700425
This commit is contained in:
Rob Coekaerts
2022-09-02 13:29:15 +02:00
parent c78bfc1463
commit 252d7f4b39
6 changed files with 41 additions and 13 deletions
+2 -2
View File
@@ -107,9 +107,9 @@ class HrEmployeeBase(models.AbstractModel):
for employee in self:
state = 'to_define'
if check_login:
if employee.user_id.im_status == 'online':
if employee.user_id.im_status in ['online', 'leave_online']:
state = 'present'
elif employee.user_id.im_status == 'offline' and employee.id not in working_now_list:
elif employee.user_id.im_status in ['offline', 'leave_offline'] and employee.id not in working_now_list:
state = 'absent'
employee.hr_presence_state = state
+1
View File
@@ -13,6 +13,7 @@ class ResConfigSettings(models.TransientModel):
related='company_id.resource_calendar_id', readonly=False)
module_hr_presence = fields.Boolean(string="Advanced Presence Control")
module_hr_skills = fields.Boolean(string="Skills Management")
module_hr_homeworking = fields.Boolean(string="Homeworking")
hr_presence_control_login = fields.Boolean(string="Based on user status in system", config_parameter='hr.hr_presence_control_login')
hr_presence_control_email = fields.Boolean(string="Based on number of emails sent", config_parameter='hr_presence.hr_presence_control_email')
hr_presence_control_ip = fields.Boolean(string="Based on IP Address", config_parameter='hr_presence.hr_presence_control_ip')
+15 -7
View File
@@ -49,6 +49,7 @@
<field name="user_id" invisible="1"/>
<field name="user_partner_id" invisible="1"/>
<field name="hr_presence_state" invisible="1"/>
<field name="hr_icon_display" invisible="1"/>
<field name="image_128" invisible="1" />
<field name="company_id" invisible="1"/>
<header>
@@ -66,9 +67,14 @@
<field name="last_activity_time" invisible="1"/>
<field name="last_activity" invisible="1"/>
<div id="hr_presence_status" attrs="{'invisible': ['|', ('last_activity', '=', False), ('user_id', '=', False)]}" class="ms-1">
<small role="img" class="fa fa-fw fa-circle text-success o_button_icon hr_presence align-middle fs-6" attrs="{'invisible': [('hr_presence_state', '!=', 'present')]}" aria-label="Available" title="Available"/>
<small role="img" class="fa fa-fw fa-circle text-warning o_button_icon hr_presence align-middle fs-6" attrs="{'invisible': [('hr_presence_state', '!=', 'to_define')]}" aria-label="Away" title="Away"/>
<small role="img" class="fa fa-fw fa-circle text-danger o_button_icon hr_presence align-middle fs-6" attrs="{'invisible': [('hr_presence_state', '!=', 'absent')]}" aria-label="Not available" title="Not available"/>
<!-- Employee is present/connected and it is normal according to his work schedule -->
<small role="img" class="fa fa-fw fa-circle text-success o_button_icon hr_presence align-middle fs-6" attrs="{'invisible': [('hr_icon_display', '!=', 'presence_present')]}" aria-label="Present" title="Present"/>
<!-- Employee is not present and it is normal according to his work schedule -->
<small role="img" class="fa fa-fw fa-circle-o text-muted o_button_icon hr_presence align-middle fs-6" attrs="{'invisible': [('hr_icon_display', '!=', 'present_absent')]}" aria-label="Absent" title="Absent" name="presence_absent"/>
<!-- Employee is connected but according to his work schedule, he should not work for now -->
<small role="img" class="fa fa-fw fa-circle-o text-success o_button_icon hr_presence align-middle fs-6" attrs="{'invisible': [('hr_icon_display', '!=', 'presence_absent_active')]}" aria-label="Present but not active" title="Present but not active" name="presence_absent_active"/>
<!-- Employee is not here but according to his work schedule, he should be connected -->
<small role="img" class="fa fa-fw fa-circle text-warning o_button_icon hr_presence align-middle fs-6" attrs="{'invisible': [('hr_icon_display', '!=', 'presence_to_define')]}" aria-label="To define" title="To define" name="presence_to_define"/>
</div>
<a title="Chat" icon="fa-comments" t-on-click.prevent="() => openChat(props.record.resId)" href="#" class="ml8 o_employee_chat_btn" invisible="not context.get('chat_icon')" attrs="{'invisible': [('user_id','=', False)]}" role="button"><i class="fa fa-comments align-middle fs-6"/></a>
</h1>
@@ -231,7 +237,7 @@
<field name="name">hr.employee.tree</field>
<field name="model">hr.employee</field>
<field name="arch" type="xml">
<tree string="Employees" multi_edit="1" sample="1" js_class="hr_employee_list">
<tree string="Employees" expand="context.get('expand', False)" multi_edit="1" sample="1" js_class="hr_employee_list">
<header>
<button name="%(plan_wizard_action)d" type="action" string="Launch Plan" context="{'action_plan': True}"/>
</header>
@@ -434,11 +440,13 @@
<record id="act_employee_from_department" model="ir.actions.act_window">
<field name="name">Employees</field>
<field name="res_model">hr.employee</field>
<field name="view_mode">kanban,form,tree</field>
<field name="view_mode">tree,kanban,form</field>
<field name="search_view_id" ref="view_employee_filter"/>
<field name="context">{
"searchpanel_default_department_id": active_id,
"default_department_id": active_id}
"default_department_id": active_id,
"search_default_group_department": 1,
"search_default_department_id": active_id,
"expand": 1}
</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
+12 -1
View File
@@ -11,7 +11,6 @@
<h2>Employees</h2>
<div class="row mt16 o_settings_container" name="employees_setting_container">
<div class="col-12 col-lg-6 o_setting_box" id="presence_control_setting" title="Presence of employees">
<div class="o_setting_right_pane">
<span class="o_form_label">Presence Control</span>
<div class="content-group" name="hr_presence_options">
@@ -88,6 +87,18 @@
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="home_working_setting">
<div class="o_setting_left_pane">
<field name="module_hr_homeworking"/>
</div>
<div class="o_setting_right_pane">
<label for="module_hr_homeworking"/>
<div class="text-muted">
Display Homeworking settings for each employee and dedicated reports.
Presence icons will be updated with homeworking location.
</div>
</div>
</div>
</div>
<h2>Employee Update Rights</h2>
<div class="row mt16 o_settings_container" name="employee_rights_setting_container">
+10 -2
View File
@@ -50,7 +50,9 @@
<xpath expr="//div[hasclass('o_kanban_card_lower_content')]" position="inside">
<t groups="hr_holidays.group_hr_holidays_user">
<div class="row o_kanban_primary_bottom bottom_block">
<div class="row o_kanban_primary_bottom bottom_block"
style="background-color: white"
t-if="record.absence_of_today.raw_value > 0">
<div class="col-3">
<a name="%(hr_employee_action_from_department)d" type="action" title="Absent Employee(s), Whose time off requests are either confirmed or validated on today">Absence</a>
</div>
@@ -159,9 +161,15 @@
<field name="arch" type="xml">
<xpath expr="//div[@id='hr_presence_status']" position="attributes">
<attribute name="attrs">
{'invisible': ['|', '|', '|', ('last_activity', '=', False), ('is_absent', '=', True), ('user_id', '=', False), ('id', '=', False)]}
{'invisible': ['|', '|', ('last_activity', '=', False), ('user_id', '=', False), ('id', '=', False)]}
</attribute>
</xpath>
<xpath expr="//div[@id='hr_presence_status']" position="inside">
<!-- Employee is absent, in holiday but he is connected -->
<div role="img" class="fa fa-fw fa-plane text-success o_button_icon hr_presence" attrs="{'invisible': [('hr_icon_display', '!=', 'presence_holiday_present')]}" aria-label="Present but on leave" title="Present but on leave" name="presence_absent_active"/>
<!-- Employee is on holiday, not present and not connected -->
<div role="img" class="fa fa-fw fa-plane text-warning o_button_icon hr_presence" attrs="{'invisible': [('hr_icon_display', '!=', 'presence_holiday_absent')]}" aria-label="On Leave" title="On Leave" name="presence_absent"/>
</xpath>
<xpath expr="//group[@name='managers']" position="inside">
<field name="leave_manager_id"/>
</xpath>
@@ -379,7 +379,7 @@ class HrContract(models.Model):
# retrieve contracts for the current month
today = fields.Date.today()
start = today + relativedelta(day=1, hour=0)
stop = today + relativedelta(month=start.month + 1, day=31, hour=23, minute=59, second=59)
stop = today + relativedelta(months=1, day=31, hour=23, minute=59, second=59)
contracts = self.env['hr.employee']._get_all_contracts(
start, stop, states=['open', 'close'])
# determine contracts to do (the ones whose generated dates have open periods this month)