fix(fusion_clock): code-review hardening [19.0.5.0.1]
- _cron_generate: per-rule savepoint isolation (one bad rule can't abort the whole daily batch) - fclk_attach_recurrence: clear an existing recurrence first (no orphaned rule generating forever) - fclk_apply_planner_cell: collapse split rows (search was limit=1 after the UNIQUE drop, orphaning extras) - fclk_release_shift: reject non-posted/open shifts (raw-POST guard) - delete_open_shift: report success=false when nothing was deleted + JS surfaces it - _generate: log before removing an empty recurrence Tests added for collapse, re-attach, draft-release. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -83,6 +83,21 @@ class TestRecurrence(TransactionCase):
|
||||
self.assertNotIn(date(2026, 6, 8), dates, "Leave day should be skipped")
|
||||
self.assertIn(date(2026, 6, 15), dates)
|
||||
|
||||
def test_reattach_recurrence_replaces_old_rule(self):
|
||||
seed = self._seed(date(2026, 6, 1))
|
||||
rule1 = self.Schedule.fclk_attach_recurrence(seed, {
|
||||
'repeat_interval': 1, 'repeat_unit': 'week',
|
||||
'repeat_type': 'x_times', 'repeat_number': 3})
|
||||
rule1_id = rule1.id
|
||||
rule2 = self.Schedule.fclk_attach_recurrence(seed, {
|
||||
'repeat_interval': 1, 'repeat_unit': 'week',
|
||||
'repeat_type': 'x_times', 'repeat_number': 2})
|
||||
# The old rule must be gone (not left generating forever) and the seed
|
||||
# must point at the new rule.
|
||||
self.assertFalse(
|
||||
self.env['fusion.clock.schedule.recurrence'].browse(rule1_id).exists())
|
||||
self.assertEqual(seed.recurrence_id, rule2)
|
||||
|
||||
def test_clear_recurrence_unlinks_rule_when_empty(self):
|
||||
seed = self._seed(date(2026, 6, 1))
|
||||
rule = self.Schedule.fclk_attach_recurrence(seed, {
|
||||
|
||||
Reference in New Issue
Block a user