Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] hr_attendance_break #142

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions hr_attendance_break/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
===========
Work breaks
===========

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8e846363bbf23a871d39db16370bbd9be190261df6cb79caa6a982eaba0f7c77
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--attendance-lightgray.png?logo=github
:target: https://github.com/OCA/hr-attendance/tree/15.0/hr_attendance_break
:alt: OCA/hr-attendance
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/hr-attendance-15-0/hr-attendance-15-0-hr_attendance_break
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-attendance&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module lets employees take breaks on the attendance screen:

.. figure:: https://raw.githubusercontent.com/OCA/hr-attendance/15.0/hr_attendance_break/static/description/hr_attendance_break.png

This allows them to check in at the beginning of the working day, check out at the end and record breaks in between.

To be sure employees take enough breaks, there's also flagging for employees who didn't take enough breaks.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

- Go to Attendances/Configuration/Settings, sections Breaks
- Fill in the minimum length of a break to be counted
- If you want to enforce a minimum amount of break taken for a certain amount of hours worked per day, click ``Edit thresholds for mandatory breaks``
- Review the server action linked there, you can ie disable imposing mandatory breaks, or rewrite the mail template informing about this

Usage
=====

To use this module, you need to:

#. Go to Attendances/Attendances
#. Click Show/Edit breaks

or

#. Go to your check in screen
#. After checking in, click the coffee mug for starting a break, and click the gears for ending it

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-attendance/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/hr-attendance/issues/new?body=module:%20hr_attendance_break%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Hunki Enterprises BV
* verdigado eG

Contributors
~~~~~~~~~~~~

* Holger Brunn <[email protected]> (https://hunki-enterprises.com)

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px
:target: https://github.com/hbrunn
:alt: hbrunn

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-hbrunn|

This module is part of the `OCA/hr-attendance <https://github.com/OCA/hr-attendance/tree/15.0/hr_attendance_break>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions hr_attendance_break/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
45 changes: 45 additions & 0 deletions hr_attendance_break/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2023 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

{
"name": "Work breaks",
"summary": "Allows employees to manage their work breaks",
"version": "15.0.1.0.0",
"development_status": "Beta",
"category": "Human Resources/Attendances",
"website": "https://github.com/OCA/hr-attendance",
"author": "Hunki Enterprises BV, Odoo Community Association (OCA), verdigado eG",
"maintainers": ["hbrunn"],
"license": "AGPL-3",
"depends": [
"hr_attendance",
"hr_attendance_reason",
],
"data": [
"security/hr_attendance_break.xml",
"security/ir.model.access.csv",
"data/hr_attendance_reason.xml",
"data/mail_activity_type.xml",
"data/mail_template.xml",
"data/ir_actions_server.xml",
"data/ir_cron.xml",
"views/hr_attendance.xml",
"views/hr_attendance_break.xml",
"views/hr_attendance_break_threshold.xml",
"views/hr_attendance_reason.xml",
"views/hr_attendance_report.xml",
"views/res_config_settings.xml",
],
"demo": [
"demo/res_company.xml",
],
"assets": {
"web.assets_backend": [
"hr_attendance_break/static/src/js/hr_attendance_break.js",
"hr_attendance_break/static/src/scss/hr_attendance_break.scss",
],
"web.assets_qweb": [
"hr_attendance_break/static/src/xml/hr_attendance_break.xml",
],
},
}
11 changes: 11 additions & 0 deletions hr_attendance_break/data/hr_attendance_reason.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data noupdate="True">
<record id="reason_imposed" model="hr.attendance.reason">
<field name="name">Imposed break</field>
<field name="action_type">break</field>
<field name="show_on_attendance_screen" eval="False" />
<field name="bypass_minimum_break" eval="True" />
</record>
</data>
39 changes: 39 additions & 0 deletions hr_attendance_break/data/ir_actions_server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data noupdate="True">
<record id="action_mandatory_break_activity" model="ir.actions.server">
<field name="name">Flag mandatory breaks</field>
<field name="state">next_activity</field>
<field name="model_id" ref="hr.model_hr_employee" />
<field name="activity_type_id" ref="activity_type_mandatory_break" />
<field name="activity_user_type">generic</field>
<field name="activity_user_field_name">user_id</field>
<field
name="activity_note"
>You didn't record enough break time, please adjust your time record</field>
</record>
<record id="action_mandatory_break_impose" model="ir.actions.server">
<field name="name">Impose mandatory breaks</field>
<field name="state">code</field>
<field name="model_id" ref="hr_attendance.model_hr_attendance" />
<field
name="code"
>env.context.get('hr_attendance_break_attendances', model)._impose_break(env.context.get('hr_attendance_break_threshold', env['hr.attendance.break.threshold']).min_break - env.context.get('hr_attendance_break_hours', 0))</field>
</record>
<record id="action_mandatory_break_email" model="ir.actions.server">
<field name="name">Mail about mandatory breaks</field>
<field name="state">email</field>
<field name="model_id" ref="hr_attendance.model_hr_employee" />
<field name="template_id" ref="template_mandatory_break" />
</record>
<record id="action_mandatory_break" model="ir.actions.server">
<field name="name">Take action if employee didn't take mandatory break</field>
<field name="state">multi</field>
<field name="model_id" ref="hr.model_hr_employee" />
<field
name="child_ids"
eval="[(6, 0, [ref('action_mandatory_break_activity'), ref('action_mandatory_break_impose'), ref('action_mandatory_break_email')])]"
/>
</record>
</data>
13 changes: 13 additions & 0 deletions hr_attendance_break/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data noupdate="True">
<record id="cron_mandatory_breaks" model="ir.cron">
<field name="name">Flag mandatory breaks</field>
<field name="model_id" ref="hr.model_hr_employee" />
<field name="interval_type">days</field>
<field name="interval_number">1</field>
<field name="numbercall">-1</field>
<field name="code">model.search([])._check_mandatory_break_yesterday()</field>
</record>
</data>
10 changes: 10 additions & 0 deletions hr_attendance_break/data/mail_activity_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data>
<record id="activity_type_mandatory_break" model="mail.activity.type">
<field name="name">Take mandatory breaks</field>
<field name="icon">fa-coffee</field>
<field name="res_model">hr.employee</field>
</record>
</data>
37 changes: 37 additions & 0 deletions hr_attendance_break/data/mail_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data noupdate="True">
<record id="template_mandatory_break" model="mail.template">
<field name="name">Attendance: Mandatory break</field>
<field name="model_id" ref="hr.model_hr_employee" />
<field
name="subject"
>Please review your breaks from {{ format_date(ctx.get('hr_attendance_break_date', object.last_attendance_id.check_in)) }}</field>
<field name="email_to">{{ object.work_email or object.user_id.email }}</field>
<field
name="email_cc"
>{{ object.parent_id.work_email or object.parent_id.user_id.email }}</field>
<field name="body_html" type="html">
<p>Dear <t t-out="object.name" />,</p>
<p>on <t
t-out="format_date(ctx.get('hr_attendance_break_date', object.last_attendance_id.check_in))"
/>, you only took <t
t-out="format_duration(ctx.get('hr_attendance_break_hours') or 0)"
/> hours of break, while you should have been taking <t
t-out="format_duration(ctx.get('hr_attendance_break_threshold', object.env['hr.attendance.break.threshold']).min_break)"
/> hours.</p>
<p>Please review the attendances below:</p>
<ul>
<li
t-foreach="ctx.get('hr_attendance_break_attendances', object.last_attendance_id)"
t-as="attendance"
>
<a
t-attf-href="/mail/view?model={{ attendance._name }}&amp;res_id={{ attendance.id }}"
><t t-out="attendance.display_name" /></a>
</li>
</ul>
</field>
</record>
</data>
12 changes: 12 additions & 0 deletions hr_attendance_break/demo/res_company.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data>
<record id="base.main_company" model="res.company">
<field name="hr_attendance_break_min_break">0.25</field>
<field
name="hr_attendance_break_threshold_ids"
eval="[(6, 0, []), (0, 0, {'min_hours': 6, 'min_break': .5}), (0, 0, {'min_hours': 9, 'min_break': .75})]"
/>
</record>
</data>
9 changes: 9 additions & 0 deletions hr_attendance_break/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from . import hr_employee
from . import hr_employee_public
from . import hr_attendance
from . import hr_attendance_break
from . import hr_attendance_break_threshold
from . import hr_attendance_report
from . import hr_attendance_reason
from . import res_config_settings
from . import res_company
Loading
Loading