Skip to content

Commit

Permalink
[hr_timesheet_attendance_schedule] 8.0.4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mikevhe18 committed Feb 22, 2021
1 parent 6208fa6 commit cfe18af
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hr_timesheet_attendance_schedule/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# pylint: disable=locally-disabled, manifest-required-author
{
"name": "Timesheet Attendance Schedule",
"version": "8.0.4.0.0",
"version": "8.0.4.1.0",
"category": "Human Resource",
"website": "https://simetri-sinergi.id",
"author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia",
Expand Down
31 changes: 30 additions & 1 deletion hr_timesheet_attendance_schedule/models/hr_attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from dateutil.relativedelta import relativedelta
from openerp import models, fields, api
from openerp import models, fields, api, _
from openerp.exceptions import Warning as UserError


class HrAttendance(models.Model):
Expand Down Expand Up @@ -37,3 +38,31 @@ def _compute_schedule(self):
compute="_compute_schedule",
store=True,
)

@api.constrains(
"schedule_id",
)
def _check_att_sign_in_out(self):
for document in self:
company = document.employee_id.company_id

if not document.schedule_id:
continue

if company.max_att_sign_in > 0:
len_att_sign_in = \
len(document.schedule_id.attendance_ids.filtered(
lambda x: x.action == "sign_in"))
if len_att_sign_in > company.max_att_sign_in:
msg = _("Total Sign In has reached maximum "
"attempts per schedule")
raise UserError(msg)

if company.max_att_sign_out > 0:
len_att_sign_out = \
len(document.schedule_id.attendance_ids.filtered(
lambda x: x.action == "sign_out"))
if len_att_sign_out > company.max_att_sign_out:
msg = _("Total Sign Out has reached maximum "
"attempts per schedule")
raise UserError(msg)
10 changes: 10 additions & 0 deletions hr_timesheet_attendance_schedule/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ class ResCompany(models.Model):
column1="company_id",
column2="group_id",
)
max_att_sign_in = fields.Integer(
string="Maximum Of Sign In",
default=0,
required=False,
)
max_att_sign_out = fields.Integer(
string="Maximum Of Sign Out",
default=0,
required=False,
)
8 changes: 8 additions & 0 deletions hr_timesheet_attendance_schedule/models/res_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ class ResConfig(models.TransientModel):
comodel_name="res.groups",
related="company_id.schedule_change_restart_val_grp_ids",
)
max_att_sign_in = fields.Integer(
string="Maximum Of Sign In",
related="company_id.max_att_sign_in",
)
max_att_sign_out = fields.Integer(
string="Maximum Of Sign Out",
related="company_id.max_att_sign_out",
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
<field name="late_attendance_buffer" widget="float_time" class="oe_inline"/>
<label for="id" string="hour(s)" class="oe_inline"/>
</div>
<div>
<label for="id" string="Maximum Of Sign In" class="oe_inline"/>
<field name="max_att_sign_in" class="oe_inline"/>
<label for="id" string="per schedule" class="oe_inline"/>
</div>
<div>
<label for="id" string="Maximum Of Sign Out" class="oe_inline"/>
<field name="max_att_sign_out" class="oe_inline"/>
<label for="id" string="per schedule" class="oe_inline"/>
</div>
</xpath>
<xpath expr="//group[@name='general_configuration']" position="after">
<separator string="Attendance Schedule Change"/>
Expand Down

0 comments on commit cfe18af

Please sign in to comment.