feat(fusion_clock): planning -> native data migration [A8]
post-migrate(19.0.5.0.0) -> fusion.clock.schedule._fclk_port_planning_data: planning.role -> fusion.clock.role, employee default/allowed roles, and planning.slot -> fusion.clock.schedule (local date+float, role map, posted if published, open if unassigned). Guarded (no-op on Community), idempotent (marker), per-row savepoints. Integration test runs on Enterprise clones. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
49
fusion_clock/tests/test_planning_migration.py
Normal file
49
fusion_clock/tests/test_planning_migration.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
#
|
||||
# Integration test for the planning -> native port. Runs only where Odoo
|
||||
# Planning is installed (Enterprise); a no-op skip on Community / local dev.
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
@tagged('-at_install', 'post_install', 'fusion_clock')
|
||||
class TestPlanningMigration(TransactionCase):
|
||||
|
||||
def test_port_planning_data(self):
|
||||
if 'planning.slot' not in self.env:
|
||||
self.skipTest('planning not installed (Community / local dev)')
|
||||
|
||||
prole = self.env['planning.role'].create({'name': 'PortLead', 'color': 5})
|
||||
emp = self.env['hr.employee'].create({'name': 'Porty McPort'})
|
||||
if 'default_planning_role_id' in emp._fields:
|
||||
emp.default_planning_role_id = prole.id
|
||||
self.env['planning.slot'].create({
|
||||
'resource_id': emp.resource_id.id,
|
||||
'company_id': emp.company_id.id,
|
||||
'start_datetime': datetime(2026, 6, 1, 14, 0, 0),
|
||||
'end_datetime': datetime(2026, 6, 1, 22, 0, 0),
|
||||
'role_id': prole.id,
|
||||
'state': 'published',
|
||||
})
|
||||
|
||||
counts = self.env['fusion.clock.schedule']._fclk_port_planning_data()
|
||||
|
||||
self.assertGreaterEqual(counts['roles'], 1)
|
||||
self.assertTrue(
|
||||
self.env['fusion.clock.role'].search([('name', '=ilike', 'PortLead')]),
|
||||
"planning.role should be ported to a native fusion.clock.role")
|
||||
|
||||
emp.invalidate_recordset()
|
||||
if 'default_planning_role_id' in emp._fields:
|
||||
self.assertTrue(emp.x_fclk_default_role_id,
|
||||
"employee default planning role should be ported")
|
||||
|
||||
sched = self.env['fusion.clock.schedule'].search([('employee_id', '=', emp.id)])
|
||||
self.assertTrue(sched, "published planning.slot should become a native schedule row")
|
||||
self.assertEqual(sched[0].state, 'posted',
|
||||
"published slots port as posted schedule entries")
|
||||
Reference in New Issue
Block a user