This commit is contained in:
gsinghpal
2026-04-27 00:11:18 -04:00
parent d9f58b9851
commit f08f328688
116 changed files with 9891 additions and 359 deletions

View File

@@ -5,7 +5,8 @@
from datetime import timedelta
from odoo import api, fields, models
from odoo import _, api, fields, models
from odoo.exceptions import UserError
class FpBakeWindow(models.Model):
@@ -247,12 +248,48 @@ class FpBakeWindow(models.Model):
# Actions
# ==========================================================================
def action_start_bake(self):
"""Move into bake_in_progress.
Hard guard: cannot start a bake on a missed_window record without
manager override (context `fp_skip_missed_window=True`). AS9100 /
Nadcap can't be retroactively documented — starting a bake after
the window means the parts are likely scrap. The override exists
for the rare case the customer accepts a deviation in writing;
every override posts to chatter so the audit trail is intact.
"""
skip = self.env.context.get('fp_skip_missed_window')
is_manager = self.env.user.has_group(
'fusion_plating.group_fusion_plating_manager'
)
for rec in self:
if rec.state == 'missed_window':
if not skip or not is_manager:
raise UserError(_(
'Bake window %s has expired (required by %s). '
'A manager must override via the "Force Start "'
'(missed window)" action — the override is '
'logged on chatter for audit. Otherwise the '
'parts must be scrapped.'
) % (rec.name, rec.bake_required_by))
rec.message_post(body=_(
'MANAGER OVERRIDE: bake started after missed window. '
'Window required by %s — actual start %s. Customer '
'deviation must be on file.'
) % (rec.bake_required_by, fields.Datetime.now()))
rec.write({
'state': 'bake_in_progress',
'bake_start_time': fields.Datetime.now(),
})
def action_force_start_missed(self):
"""Manager-only: force-start a bake on a missed_window record.
Just calls action_start_bake with the override context. Exists
as a separate button so the form view can guard visibility on
manager group.
"""
return self.with_context(fp_skip_missed_window=True).action_start_bake()
def action_end_bake(self):
for rec in self:
vals = {