refactor(jobs): address code review feedback on fp.job.step (Task 1.6)

- I1: Replace 'Task 1.6' markers in stub method comments and
  NotImplementedError messages with forward-looking phrasing.
  Task 1.6 is what just shipped (the field expansion); the action
  stubs are deferred to an unspecified future task. Stale markers
  would have confused future readers/operators.
- I2: Add test_cost_total_recomputes_when_rate_changes — insurance
  test that verifies @api.depends('cost_per_hour') triggers through
  the related-from-work_centre chain. Catches future Odoo upgrades
  that break related-depends.

Manifest 19.0.8.5.0 → 19.0.8.5.1.

Part of: native job model migration (spec 2026-04-25)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-24 22:22:15 -04:00
parent 91767f9f03
commit 57a3aea16f
3 changed files with 24 additions and 7 deletions

View File

@@ -103,3 +103,20 @@ class TestFpJobStepStateMachine(TransactionCase):
step.duration_actual = 30.0
# Recompute happens on read after a write to a depends field
self.assertEqual(step.cost_total, 30.0)
def test_cost_total_recomputes_when_rate_changes(self):
# Insurance test: verify @api.depends('cost_per_hour') triggers
# through the related-from-work_centre chain. If a future Odoo
# upgrade breaks related-depends, this test catches it.
wc = self.env['fp.work.centre'].create({
'name': 'WC4', 'code': 'WC4', 'kind': 'wet_line',
'cost_per_hour': 60.0,
})
step = self._make_step(work_centre_id=wc.id)
step.duration_actual = 30.0
self.assertEqual(step.cost_total, 30.0)
# Change the rate; cost_total should recompute.
wc.cost_per_hour = 120.0
# Force recompute via invalidate (Odoo recomputes on next read).
step.invalidate_recordset(['cost_total'])
self.assertEqual(step.cost_total, 60.0)