Skip to content

Commit

Permalink
[MIG] hr_attendance_autoclose: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-lopez-tecnativa committed Aug 14, 2024
1 parent 96b0b19 commit 6bec8b7
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 63 deletions.
2 changes: 1 addition & 1 deletion hr_attendance_autoclose/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "HR Attendance Auto Close",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Human Resources",
"summary": "Close stale Attendances",
"website": "https://github.com/OCA/hr-attendance",
Expand Down
21 changes: 13 additions & 8 deletions hr_attendance_autoclose/tests/test_hr_attendance_auto_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@

from dateutil.relativedelta import relativedelta

from odoo.tests import common, new_test_user, users
from odoo.tests import new_test_user, users
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DF

from odoo.addons.base.tests.common import BaseCommon

class TestHrAttendanceReason(common.TransactionCase):
def setUp(self):
super().setUp()
self.hr_attendance = self.env["hr.attendance"]
self.employee = self.env["hr.employee"].create({"name": "Employee"})
new_test_user(self.env, login="test-user")

class TestHrAttendanceReason(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.hr_attendance = cls.env["hr.attendance"]
cls.employee = cls.env["hr.employee"].create({"name": "Employee"})
new_test_user(cls.env, login="test-user")

def test_employee_edit(self):
dti = datetime.now()
Expand All @@ -35,7 +38,9 @@ def test_employee_edit(self):
{"employee_id": self.employee.id, "check_in": dt.strftime(DF)}
)
self.hr_attendance.check_for_incomplete_attendances()
self.assertEqual(att.worked_hours, 11.0, "Attendance not closed")
# worked_hours are now 10 hours, because Odoo adds 1 hour to lunch, see:
# https://github.com/odoo/odoo/commit/2eda54348de1bd42fc2a1bed94cd8b7a3ebf405d
self.assertEqual(att.worked_hours, 10.0, "Attendance not closed")
reason = self.env.company.hr_attendance_autoclose_reason
reason.unlink()
dti += relativedelta(hours=10)
Expand Down
2 changes: 1 addition & 1 deletion hr_attendance_autoclose/views/hr_attendance_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<field name="open_worked_hours" widget="float_time" />
</field>
<field name="worked_hours" position="attributes">
<attribute name="invisible">1</attribute>
<attribute name="column_invisible">1</attribute>
</field>
</field>
</record>
Expand Down
99 changes: 46 additions & 53 deletions hr_attendance_autoclose/views/res_config_settings_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,59 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="hr_attendance.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@data-key='hr_attendance']" position="inside">
<h2>Attendance Autoclosing</h2>
<div
class="row mt16 o_settings_container"
<xpath expr="//app[@name='hr_attendance']" position="inside">
<block
title="Attendance Autoclosing"
name="attendance_autoclose_settings_container"
>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane" />
<div class="o_setting_right_pane">
<label
string="Max Hours Per Day"
for="attendance_maximum_hours_per_day"
/>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="row">
<div class="text-muted col-lg-8">
Attendance lines longer than this value will
be automatically closed.
</div>
</div>
<div class="content-group mt16">
<field
name="attendance_maximum_hours_per_day"
widget="float_time"
/>
<setting>
<label
string="Max Hours Per Day"
for="attendance_maximum_hours_per_day"
/>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="row">
<div class="text-muted col-lg-8">
Attendance lines longer than this value will
be automatically closed.
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane" />
<div class="o_setting_right_pane">
<label
string="Autoclose Reason"
for="hr_attendance_autoclose_reason"
/>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
groups="base.group_multi_company"
<div class="content-group mt16">
<field
name="attendance_maximum_hours_per_day"
widget="float_time"
/>
<div class="row">
<div class="text-muted col-lg-8">
This reason will be added to an attendance
when it's autoclosed.
</div>
</div>
<div class="content-group mt16">
<field
name="hr_attendance_autoclose_reason"
can_create="true"
can_write="true"
/>
</div>
</setting>
<setting>
<label
string="Autoclose Reason"
for="hr_attendance_autoclose_reason"
/>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="row">
<div class="text-muted col-lg-8">
This reason will be added to an attendance
when it's autoclosed.
</div>
</div>
</div>
</div>
<div class="content-group mt16">
<field
name="hr_attendance_autoclose_reason"
can_create="true"
can_write="true"
/>
</div>
</setting>
</block>
</xpath>
</field>
</record>
Expand Down

0 comments on commit 6bec8b7

Please sign in to comment.