refactor(jobs): address code review feedback on fp.job (Task 1.4)
- Move NOTE comment from between @api.depends and the function into a proper docstring on _compute_costs. - Make currency_id required=True (default still in place — only a programmatic write would null it, but Monetary fields need a non-null anchor). - Add test_current_location_for_confirmed to cover the title-case fallback branch in _compute_current_location. Manifest 19.0.8.3.0 → 19.0.8.3.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:
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating',
|
||||
'version': '19.0.8.3.0',
|
||||
'version': '19.0.8.3.1',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Core plating / metal finishing ERP: facilities, processes, tanks, baths, jobs, operators.',
|
||||
'description': """
|
||||
|
||||
@@ -122,6 +122,7 @@ class FpJob(models.Model):
|
||||
# ------------------------------------------------------------------
|
||||
currency_id = fields.Many2one(
|
||||
'res.currency',
|
||||
required=True,
|
||||
default=lambda self: self.env.company.currency_id,
|
||||
)
|
||||
quoted_revenue = fields.Monetary(
|
||||
@@ -141,9 +142,13 @@ class FpJob(models.Model):
|
||||
)
|
||||
|
||||
@api.depends('quoted_revenue')
|
||||
# NOTE: when fp.job.step lands in Task 1.5, this dependency expands
|
||||
# to include 'step_ids.cost_total'. For now actual_cost is always 0.
|
||||
def _compute_costs(self):
|
||||
"""Cost rollup for the job header.
|
||||
|
||||
TODO(Task 1.5): when fp.job.step lands, expand @api.depends to
|
||||
include 'step_ids.cost_total' so actual_cost rolls up
|
||||
step time × work_centre.cost_per_hour automatically.
|
||||
"""
|
||||
for job in self:
|
||||
job.actual_cost = 0.0
|
||||
job.margin = job.quoted_revenue - job.actual_cost
|
||||
|
||||
@@ -86,3 +86,9 @@ class TestFpJobStateMachine(TransactionCase):
|
||||
self.assertEqual(job.actual_cost, 0.0)
|
||||
self.assertEqual(job.margin, 1000.0)
|
||||
self.assertEqual(job.margin_pct, 100.0)
|
||||
|
||||
def test_current_location_for_confirmed(self):
|
||||
job = self._make_job()
|
||||
job.action_confirm()
|
||||
# Forces compute via field read; expect title-cased state
|
||||
self.assertEqual(job.current_location, 'Confirmed')
|
||||
|
||||
Reference in New Issue
Block a user