Files
Odoo-Modules/fusion_plating/fusion_plating_jobs/models/res_users.py
gsinghpal 0d85063b5e feat(numbering): wire CoC/RCV/DLV/PU into parent-numbered mixin + rename counters
Per-model counter fields on sale.order renamed to x_fc_pn_*_count
to avoid collision with pre-existing compute fields of the same
short name in bridge_mrp / receiving / configurator (silent
compute-override was suppressing the storage). 4 child models
(fp.certificate, fp.receiving, fusion.plating.delivery,
fusion.plating.pickup.request) now derive names as PFX-<parent>
with -NN suffix from the 2nd onward.

fusion.plating.pickup.request gains a sale_order_id field
(optional) so pickups created against an SO get parent-derived
names, while standalone pickups (pre-SO) fall back to PU/YYYY/NNNN.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 13:30:37 -04:00

50 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
from odoo import api, fields, models
class ResUsers(models.Model):
_inherit = 'res.users'
x_fc_initials = fields.Char(
string='Plating Initials',
help='Operator / inspector initials used to pre-fill signature '
'and "Reviewer Initials" style prompts in the Record Inputs '
'dialog. Editable in the dialog itself — when the user types '
'a different value and saves, it persists here for every '
'future job and step.',
)
x_fc_signature_image = fields.Binary(
string='Plating Signature',
attachment=True,
help='Drawn or uploaded signature image. Used in WO detail and '
'certificate reports for any signature-type prompt this user '
'signed off on; falls back to typed initials when blank. '
'Capture it once in user preferences; it stamps every '
'future sign-off automatically.',
)
@api.model
def _fp_default_initials(self):
"""Best-effort initials derived from the user's display name.
Used as a fallback when ``x_fc_initials`` is empty so the
operator still gets a sensible pre-fill on their first run.
E.g. "John Doe" -> "JD", "Mary Anne Smith" -> "MAS".
"""
name = (self.name or '').strip()
if not name:
return ''
return ''.join(
piece[0] for piece in name.split() if piece
).upper()[:6]
def fp_get_initials(self):
"""Resolve the user's initials for the dialog: stored override
first, fall back to the auto-derived value from their name."""
self.ensure_one()
return self.x_fc_initials or self._fp_default_initials()