feat(fusion_clock): native shift roles (fusion.clock.role) [A1-A3]
Replaces Odoo Planning's planning.role: name+colour model with the same 1-11 palette, employee default/allowed role fields, Employee Roles editor, role_id on shift template + schedule with default resolution, ACLs, menus. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,3 +11,10 @@ from . import test_settings
|
||||
from . import test_clock_kiosk
|
||||
from . import test_break_rules
|
||||
from . import test_pending_reason_exempt
|
||||
from . import test_role
|
||||
from . import test_recurrence
|
||||
from . import test_publish_range
|
||||
from . import test_open_shift
|
||||
from . import test_overnight
|
||||
from . import test_multishift_window
|
||||
from . import test_planning_migration
|
||||
|
||||
49
fusion_clock/tests/test_role.py
Normal file
49
fusion_clock/tests/test_role.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
|
||||
from odoo import fields
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
@tagged('-at_install', 'post_install', 'fusion_clock')
|
||||
class TestFusionClockRole(TransactionCase):
|
||||
|
||||
def test_default_color_in_range(self):
|
||||
role = self.env['fusion.clock.role'].create({'name': 'Cashier'})
|
||||
self.assertTrue(1 <= role.color <= 11, "Default colour should be 1..11")
|
||||
|
||||
def test_color_hex_and_open_alpha(self):
|
||||
role = self.env['fusion.clock.role'].create({'name': 'Red', 'color': 1})
|
||||
self.assertEqual(role._get_color_from_code(), '#EE4B39')
|
||||
self.assertEqual(role._get_color_from_code(True), '#EE4B3980')
|
||||
|
||||
def test_employee_default_and_allowed_roles(self):
|
||||
lead = self.env['fusion.clock.role'].create({'name': 'Lead', 'color': 3})
|
||||
cashier = self.env['fusion.clock.role'].create({'name': 'Cashier', 'color': 4})
|
||||
emp = self.env['hr.employee'].create({
|
||||
'name': 'Bob',
|
||||
'x_fclk_default_role_id': lead.id,
|
||||
'x_fclk_role_ids': [(6, 0, [lead.id, cashier.id])],
|
||||
})
|
||||
self.assertEqual(emp.x_fclk_default_role_id, lead)
|
||||
self.assertIn(cashier, emp.x_fclk_role_ids)
|
||||
|
||||
def test_schedule_inherits_employee_default_role(self):
|
||||
lead = self.env['fusion.clock.role'].create({'name': 'Lead', 'color': 3})
|
||||
emp = self.env['hr.employee'].create({'name': 'Cara', 'x_fclk_default_role_id': lead.id})
|
||||
sch = self.env['fusion.clock.schedule'].fclk_apply_planner_cell(
|
||||
emp, fields.Date.today(), {'input': '9-5'})
|
||||
self.assertEqual(sch.role_id, lead,
|
||||
"A new shift should inherit the employee's default role")
|
||||
|
||||
def test_schedule_role_from_shift_template(self):
|
||||
stock = self.env['fusion.clock.role'].create({'name': 'Stock', 'color': 5})
|
||||
shift = self.env['fusion.clock.shift'].create({
|
||||
'name': 'Morning', 'start_time': 8.0, 'end_time': 16.0, 'role_id': stock.id})
|
||||
emp = self.env['hr.employee'].create({'name': 'Dan'})
|
||||
sch = self.env['fusion.clock.schedule'].fclk_apply_planner_cell(
|
||||
emp, fields.Date.today(), {'shift_id': shift.id})
|
||||
self.assertEqual(sch.role_id, stock,
|
||||
"Shift-template role should win when employee has no default")
|
||||
Reference in New Issue
Block a user