fusion_clock doesn't depend on planning, so planning's models load AFTER it during -u and the port saw no data. Now detect planning tables via SQL, defer (no marker) when the ORM isn't loaded, and finish the port from the deploy odoo-shell step (full registry). Marker now owned by the method. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
54 lines
2.2 KiB
Python
54 lines
2.2 KiB
Python
# -*- 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)')
|
|
|
|
# Ensure the port actually runs (it is marker-guarded for production).
|
|
self.env['ir.config_parameter'].sudo().search(
|
|
[('key', '=', 'fusion_clock.planning_migrated')]).unlink()
|
|
|
|
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")
|