Permalink
Browse files

⚡️ autocheckout feature

  • Loading branch information...
KolushovAlexandr committed Feb 1, 2019
1 parent 517f9a9 commit 54feaca2ffcbd122be7af26aee9d2fb9f7e245b5
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2004-2015 Odoo S.A.
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": """Partner Attendances""",
"summary": """Manage partner attendances""",
"category": "Extra Tools",
# "live_test_url": "",
"images": [],
"version": "10.0.1.0.0",
"version": "10.0.1.1.0",
"application": False,

"author": "IT-Projects LLC, Kolushov Alexandr",
@@ -1,3 +1,8 @@
`1.1.0`
-------

- **New:** Autocheckout option - closes shifts after defined time

`1.0.0`
-------

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2004-2015 Odoo S.A.
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from datetime import datetime
@@ -110,3 +110,11 @@ def copy(self):
# [W8106(method-required-super), HrAttendance.copy] Missing `super` call in "copy" method.
super(HrAttendance, self).copy()
raise exceptions.UserError(_('You cannot duplicate an attendance.'))

@api.multi
def autocheckout_close_shifts(self):
max_interval = self.env['base.config.settings'].shift_autocheckout
shifts = self.search([('check_out', '=', False), ('worked_hours', '>=', max_interval)])
shifts.write({
'check_out': datetime.now(),
})
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2004-2015 Odoo S.A.
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from odoo import fields, models
from odoo import fields, models, api


class BaseConfigSettings(models.TransientModel):
@@ -14,3 +14,27 @@ class BaseConfigSettings(models.TransientModel):
string='Partner PIN',
help='Enable or disable partner PIN identification at check in',
implied_group="base_attendance.group_hr_attendance_use_pin")
shift_autocheckout = fields.Integer('Autocheckout ', help="Maximum Shift Time in Minutes")

@api.multi
def set_shift_autocheckout(self):
self.env["ir.config_parameter"].set_param("base_attendance.shift_autocheckout", self.shift_autocheckout)
self.checkout_shifts()

@api.multi
def get_default_shift_autocheckout(self, fields):
shift_autocheckout = self.env["ir.config_parameter"].get_param("base_attendance.shift_autocheckout", default=0)
return {'shift_autocheckout': int(shift_autocheckout)}

@api.model
def checkout_shifts(self):
cron_record = self.env.ref('base_attendance.base_attendance_autocheckout')
if self.shift_autocheckout == 0:
cron_record.write({
'active': False,
})
else:
cron_record.write({
'active': True,
'interval_number': self.shift_autocheckout
})
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2004-2015 Odoo S.A.
Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).-->
<odoo>

@@ -233,4 +233,18 @@
<menuitem id="menu_hr_attendance_kiosk_mode" name="Kiosk Mode" parent="menu_hr_attendance_manage_attendances" sequence="20" groups="base_attendance.group_hr_attendance_user" action="hr_attendance_action_kiosk_mode"/>

<menuitem id="menu_hr_attendance_report" name="Reports" parent="menu_base_attendance_root" sequence="30" groups="base_attendance.group_hr_attendance_user" action="hr_attendance_action_graph"/>

<!--IR CRON-->

<record model="ir.cron" id="base_attendance_autocheckout">
<field name="name">Generate Monthly Sales Closing</field>
<field name="active" eval="False"/>
<field name="interval_number">10</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
<field name="model" eval="'res.partner.attendance'"/>
<field name="function" eval="'autocheckout_close_shifts'"/>
</record>

</odoo>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2004-2015 Odoo S.A.
Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).-->
<odoo>
<record id="hr_attendance_view_config" model="ir.ui.view">
@@ -15,6 +15,7 @@
</header>
<group string="Settings">
<field name="group_attendance_use_pin" widget="radio"/>
<field name="shift_autocheckout"/>
</group>
</form>
</field>

0 comments on commit 54feaca

Please sign in to comment.