changes
This commit is contained in:
@@ -57,6 +57,37 @@ class FpRecordInputsController(http.Controller):
|
||||
'is_authored': True,
|
||||
})
|
||||
|
||||
# Operator initials — used by the JS dialog to pre-fill
|
||||
# signature / "Reviewer Initials" prompts. The user can edit
|
||||
# the value in the dialog and the new value is persisted back
|
||||
# via /fp/record_inputs/commit so future jobs and other steps
|
||||
# automatically pick it up.
|
||||
user = request.env.user
|
||||
try:
|
||||
user_initials = user.fp_get_initials()
|
||||
except AttributeError:
|
||||
user_initials = ''
|
||||
|
||||
# Instruction images — the recipe author's reference photos /
|
||||
# screenshots that show the operator HOW to do this step
|
||||
# (masking patterns, fixture orientation, annotated diagrams).
|
||||
# Returned as URL pointers so the dialog renders thumbnails
|
||||
# without bloating the load payload with base64.
|
||||
instruction_images = []
|
||||
if node and 'instruction_attachment_ids' in node._fields:
|
||||
for att in node.instruction_attachment_ids:
|
||||
instruction_images.append({
|
||||
'id': att.id,
|
||||
'name': att.name or '',
|
||||
'mimetype': att.mimetype or '',
|
||||
'url': '/web/image/%s' % att.id,
|
||||
})
|
||||
# Operator instructions text — shown above the prompts so the
|
||||
# author's written guidance is visible at runtime.
|
||||
instructions_html = ''
|
||||
if node and node.description:
|
||||
instructions_html = node.description
|
||||
|
||||
return {
|
||||
'ok': True,
|
||||
'step': {
|
||||
@@ -68,13 +99,16 @@ class FpRecordInputsController(http.Controller):
|
||||
'name': step.job_id.name,
|
||||
},
|
||||
'prompts': prompts,
|
||||
'user_initials': user_initials or '',
|
||||
'instructions_html': instructions_html or '',
|
||||
'instruction_images': instruction_images,
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Commit — write values via the existing wizard (reuse semantics)
|
||||
# ------------------------------------------------------------------
|
||||
@http.route('/fp/record_inputs/commit', type='jsonrpc', auth='user')
|
||||
def commit(self, step_id, values, advance_after=False):
|
||||
def commit(self, step_id, values, advance_after=False, user_initials=None):
|
||||
"""Commit operator-entered values for this step.
|
||||
|
||||
Args:
|
||||
@@ -148,6 +182,17 @@ class FpRecordInputsController(http.Controller):
|
||||
if advance_after:
|
||||
ctx['fp_advance_after_save'] = True
|
||||
result = wizard.with_context(**ctx).action_commit()
|
||||
# Persist a changed initials value on the user record so
|
||||
# the next dialog (any step, any job) auto-fills the new
|
||||
# value. Only writes when the operator explicitly typed a
|
||||
# different value than what they had stored.
|
||||
if user_initials is not None:
|
||||
cleaned = (user_initials or '').strip()
|
||||
stored = (request.env.user.x_fc_initials or '').strip()
|
||||
if cleaned and cleaned != stored:
|
||||
request.env.user.sudo().write({
|
||||
'x_fc_initials': cleaned,
|
||||
})
|
||||
return {
|
||||
'ok': True,
|
||||
'next_action': result if isinstance(result, dict) else False,
|
||||
|
||||
Reference in New Issue
Block a user