64 lines
1.8 KiB
Python
64 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2026 Nexa Systems Inc.
|
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
|
|
|
from odoo import models, fields
|
|
|
|
|
|
class FusionClockShift(models.Model):
|
|
_name = 'fusion.clock.shift'
|
|
_description = 'Clock Shift Schedule'
|
|
_order = 'sequence, name'
|
|
_rec_name = 'name'
|
|
|
|
name = fields.Char(
|
|
string='Shift Name',
|
|
required=True,
|
|
help="E.g. 'Morning Shift', 'Evening Shift'.",
|
|
)
|
|
start_time = fields.Float(
|
|
string='Start Time',
|
|
required=True,
|
|
default=9.0,
|
|
help="Shift start in 24h float (e.g. 7.0 = 7:00 AM).",
|
|
)
|
|
end_time = fields.Float(
|
|
string='End Time',
|
|
required=True,
|
|
default=17.0,
|
|
help="Shift end in 24h float (e.g. 15.0 = 3:00 PM).",
|
|
)
|
|
break_minutes = fields.Float(
|
|
string='Break Duration (min)',
|
|
default=30.0,
|
|
help="Unpaid break duration in minutes for this shift.",
|
|
)
|
|
sequence = fields.Integer(default=10)
|
|
company_id = fields.Many2one(
|
|
'res.company',
|
|
string='Company',
|
|
default=lambda self: self.env.company,
|
|
required=True,
|
|
)
|
|
active = fields.Boolean(default=True)
|
|
color = fields.Char(string='Color', default='#3B82F6')
|
|
employee_ids = fields.One2many(
|
|
'hr.employee',
|
|
'x_fclk_shift_id',
|
|
string='Assigned Employees',
|
|
)
|
|
employee_count = fields.Integer(
|
|
string='Employees',
|
|
compute='_compute_employee_count',
|
|
)
|
|
|
|
def _compute_employee_count(self):
|
|
for rec in self:
|
|
rec.employee_count = len(rec.employee_ids)
|
|
|
|
@property
|
|
def scheduled_hours(self):
|
|
"""Return the scheduled work hours for this shift (excluding break)."""
|
|
raw = self.end_time - self.start_time
|
|
return max(raw - (self.break_minutes / 60.0), 0.0)
|