feat(jobs): Phase 4 light refactors — notifications, KPI source tag

- Adds 'job_confirmed' and 'job_complete' trigger events to
  fp.notification.template (legacy 'mo_confirmed' / 'mo_complete'
  stay for bridge_mrp).
- fp.job.action_confirm and button_mark_done now fire those
  notifications best-effort via fp.notification.template._dispatch
  (silent skip if templates absent or notifications module missing).
- Adds x_fc_source ['mrp', 'jobs'] tag to fusion.plating.kpi.value
  so Phase 9 dashboards can filter or display both sources.
- Verified aerospace/nuclear/cgp/safety modules don't directly
  reference mrp.production or mrp.workorder.

Configurator integration was already covered by Task 2.5's SO
confirm hook (reads x_fc_part_catalog_id and x_fc_coating_config_id
from sale.order.line).

Manifest 19.0.1.6.0 -> 19.0.1.7.0.

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 23:38:38 -04:00
parent b359be3745
commit 51a5cbbe5d
6 changed files with 136 additions and 1 deletions

View File

@@ -462,3 +462,44 @@ class TestPhase3Refactors(TransactionCase):
[('x_fc_job_id', '=', job.id)],
)
self.assertFalse(inspections)
class TestPhase4Refactors(TransactionCase):
"""Phase 4 — light refactors batch B (notifications, KPI source tag).
Configurator integration is already covered by Task 2.5's SO confirm
hook (which reads x_fc_part_catalog_id / x_fc_coating_config_id from
sale.order.line — see TestSoConfirmHook above).
"""
def setUp(self):
super().setUp()
self.partner = self.env['res.partner'].create({'name': 'C'})
self.product = self.env['product.product'].create({'name': 'P'})
def test_kpi_value_has_source_field(self):
if 'fusion.plating.kpi.value' in self.env:
self.assertIn(
'x_fc_source',
self.env['fusion.plating.kpi.value']._fields,
)
def test_notification_template_has_job_triggers(self):
if 'fp.notification.template' in self.env:
triggers = dict(
self.env['fp.notification.template']
._fields['trigger_event'].selection
)
self.assertIn('job_confirmed', triggers)
self.assertIn('job_complete', triggers)
def test_action_confirm_calls_fire_notification(self):
# Smoke test — creates a job, confirms it, verifies no exception
# thrown by the notification path even when no templates exist.
job = self.env['fp.job'].create({
'partner_id': self.partner.id,
'product_id': self.product.id,
'qty': 1.0,
})
job.action_confirm() # Should not raise even with no templates
self.assertEqual(job.state, 'confirmed')