101 lines
3.0 KiB
Python
101 lines
3.0 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 FpValue(models.Model):
|
|
"""A single value, fundamental, core behaviour, or belief.
|
|
|
|
Values are grouped under a fusion.plating.value.set. Each value has a
|
|
short title, an optional display number (e.g. "Fundamental #3"), a
|
|
long-form description, stories / examples of living the value, and an
|
|
icon for display in kanban tiles.
|
|
"""
|
|
_name = 'fusion.plating.value'
|
|
_description = 'Fusion Plating — Value'
|
|
_order = 'set_id, sequence, number, name'
|
|
|
|
name = fields.Char(
|
|
string='Title',
|
|
required=True,
|
|
help='Short, memorable title for the value, e.g. '
|
|
'"Do What\'s Best for the Customer".',
|
|
)
|
|
sequence = fields.Integer(
|
|
string='Sequence',
|
|
default=10,
|
|
help='Display order within the set.',
|
|
)
|
|
number = fields.Integer(
|
|
string='Number',
|
|
help='Optional display number (e.g. 1, 2, 3). Shows on kanban '
|
|
'tiles and in rotation schedules.',
|
|
)
|
|
set_id = fields.Many2one(
|
|
'fusion.plating.value.set',
|
|
string='Value Set',
|
|
required=True,
|
|
ondelete='cascade',
|
|
index=True,
|
|
)
|
|
company_id = fields.Many2one(
|
|
'res.company',
|
|
string='Company',
|
|
related='set_id.company_id',
|
|
store=True,
|
|
readonly=True,
|
|
)
|
|
description = fields.Html(
|
|
string='Description',
|
|
help='Long-form explanation of what this value means and how it '
|
|
'shows up in daily work.',
|
|
)
|
|
examples = fields.Html(
|
|
string='Stories & Examples',
|
|
help='Stories, anecdotes, and concrete examples of people living '
|
|
'this value.',
|
|
)
|
|
icon = fields.Char(
|
|
string='Icon',
|
|
default='fa-star',
|
|
help='Font Awesome icon class (without the "fa " prefix), '
|
|
'e.g. "fa-heart", "fa-bolt".',
|
|
)
|
|
color = fields.Integer(
|
|
string='Color Index',
|
|
default=0,
|
|
help='Kanban colour index (0-11).',
|
|
)
|
|
active = fields.Boolean(
|
|
string='Active',
|
|
default=True,
|
|
)
|
|
recognition_ids = fields.One2many(
|
|
'fusion.plating.value.recognition',
|
|
'value_id',
|
|
string='Recognitions',
|
|
)
|
|
recognition_count = fields.Integer(
|
|
string='Recognition Count',
|
|
compute='_compute_recognition_count',
|
|
)
|
|
|
|
@api.depends('recognition_ids', 'recognition_ids.state')
|
|
def _compute_recognition_count(self):
|
|
for rec in self:
|
|
rec.recognition_count = len(rec.recognition_ids.filtered(
|
|
lambda r: r.state == 'published'
|
|
))
|
|
|
|
def name_get(self):
|
|
result = []
|
|
for rec in self:
|
|
if rec.number:
|
|
result.append((rec.id, f'#{rec.number} — {rec.name}'))
|
|
else:
|
|
result.append((rec.id, rec.name))
|
|
return result
|