changes
This commit is contained in:
40
fusion_plating/fusion_plating_jobs/models/res_users.py
Normal file
40
fusion_plating/fusion_plating_jobs/models/res_users.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# -*- 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.',
|
||||
)
|
||||
|
||||
@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()
|
||||
Reference in New Issue
Block a user