mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] hr_attendance_work_entry: Modified kiosk mode views and attendance views to allow for various punch types.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class HrAttendance(models.Model):
|
||||
@@ -7,3 +7,8 @@ class HrAttendance(models.Model):
|
||||
work_type_id = fields.Many2one('hr.work.entry.type', string='Work Type',
|
||||
default=lambda self: self.env.ref('hr_attendance_work_entry.work_input_attendance',
|
||||
raise_if_not_found=False))
|
||||
|
||||
@api.model
|
||||
def gather_attendance_work_types(self):
|
||||
work_types = self.env['hr.work.entry.type'].sudo().search([('allow_attendance', '=', True)])
|
||||
return work_types.read(['id', 'name', 'attendance_icon'])
|
||||
|
||||
@@ -5,7 +5,7 @@ from odoo.exceptions import UserError
|
||||
class HrEmployee(models.Model):
|
||||
_inherit = 'hr.employee'
|
||||
|
||||
attendance_state = fields.Selection(selection_add=[('break', 'Break')])
|
||||
attendance_state = fields.Selection(selection_add=[('break', 'Break'), ('lunch', 'Lunch')])
|
||||
|
||||
@api.depends('last_attendance_id.work_type_id')
|
||||
def _compute_attendance_state(self):
|
||||
@@ -20,6 +20,9 @@ class HrEmployee(models.Model):
|
||||
|
||||
def attendance_manual(self, next_action, entered_pin=None, work_type_id=None):
|
||||
self = self.with_context(work_type_id=work_type_id)
|
||||
if not entered_pin:
|
||||
# fix for pin mode with specific argument order for work_type_id
|
||||
entered_pin = None
|
||||
return super(HrEmployee, self).attendance_manual(next_action, entered_pin=entered_pin)
|
||||
|
||||
def _attendance_action_change(self):
|
||||
|
||||
@@ -3,6 +3,7 @@ from odoo import fields, models
|
||||
|
||||
class HrWorkEntryType(models.Model):
|
||||
_inherit = 'hr.work.entry.type'
|
||||
_order = 'sequence, id'
|
||||
|
||||
allow_attendance = fields.Boolean(string='Allow in Attendance')
|
||||
attendance_icon = fields.Char(string='Attendance Icon', default='fa-sign-in')
|
||||
@@ -10,4 +11,5 @@ class HrWorkEntryType(models.Model):
|
||||
# ('checked_out', "Checked out"), # reserved for detecting new punch in
|
||||
('checked_in', "Checked in"),
|
||||
('break', 'Break'),
|
||||
('lunch', 'Lunch'),
|
||||
], string='Attendance State', default='checked_in')
|
||||
|
||||
Reference in New Issue
Block a user