diff --git a/base_attendance/__manifest__.py b/base_attendance/__manifest__.py index af72ce8fea..ffaea7f182 100644 --- a/base_attendance/__manifest__.py +++ b/base_attendance/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2004-2015 Odoo S.A. -# Copyright 2018 Kolushov Alexandr +# Copyright 2018-2019 Kolushov Alexandr # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). { "name": """Partner Attendances""", @@ -8,7 +8,7 @@ "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", diff --git a/base_attendance/doc/changelog.rst b/base_attendance/doc/changelog.rst index 9ee2b48b8e..007f5cde00 100644 --- a/base_attendance/doc/changelog.rst +++ b/base_attendance/doc/changelog.rst @@ -1,3 +1,8 @@ +`1.1.0` +------- + +- **New:** Autocheckout option - closes shifts after defined time + `1.0.0` ------- diff --git a/base_attendance/models/res_attendance.py b/base_attendance/models/res_attendance.py index b99418e2cd..d07b2c5018 100644 --- a/base_attendance/models/res_attendance.py +++ b/base_attendance/models/res_attendance.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2004-2015 Odoo S.A. -# Copyright 2018 Kolushov Alexandr +# Copyright 2018-2019 Kolushov Alexandr # 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(), + }) diff --git a/base_attendance/models/res_config.py b/base_attendance/models/res_config.py index 4c363e49a5..1ddbb3ea8f 100644 --- a/base_attendance/models/res_config.py +++ b/base_attendance/models/res_config.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # Copyright (c) 2004-2015 Odoo S.A. -# Copyright 2018 Kolushov Alexandr +# Copyright 2018-2019 Kolushov Alexandr # 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 + }) diff --git a/base_attendance/views/res_attendance_view.xml b/base_attendance/views/res_attendance_view.xml index 0a8ccfbaff..62f46cdd87 100644 --- a/base_attendance/views/res_attendance_view.xml +++ b/base_attendance/views/res_attendance_view.xml @@ -1,6 +1,6 @@ @@ -233,4 +233,18 @@ + + + + + Generate Monthly Sales Closing + + 10 + minutes + -1 + + + + + diff --git a/base_attendance/views/res_config_view.xml b/base_attendance/views/res_config_view.xml index b461bc8504..bd4c362401 100644 --- a/base_attendance/views/res_config_view.xml +++ b/base_attendance/views/res_config_view.xml @@ -1,6 +1,6 @@ @@ -15,6 +15,7 @@ +