# -*- coding: utf-8 -*- # Copyright 2024-2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) """Symptom classification. Lookup table replacing the flat `x_fc_issue_category` Char on repair.order. One symptom class belongs to one equipment category (stairlift > "Not Moving", "Beeps Alarm", "Stops Midway"...). Together with the category, it's the key that fusion.repair.flowchart uses to look up which troubleshooting flowchart to run. """ from odoo import api, fields, models class FusionRepairSymptomClass(models.Model): _name = 'fusion.repair.symptom.class' _description = 'Repair Symptom Class' _order = 'category_id, sequence, name' name = fields.Char(string='Name', required=True, translate=True) code = fields.Char( string='Code', required=True, help='Stable code used by data files and automation (e.g. "not_moving").', ) category_id = fields.Many2one( 'fusion.repair.product.category', string='Equipment Category', required=True, index=True, ondelete='cascade', ) sequence = fields.Integer(default=10) icon = fields.Char( string='Icon', default='fa-exclamation-circle', help='Font Awesome icon class shown next to the symptom in pickers.', ) description = fields.Text(translate=True) active = fields.Boolean(default=True) company_id = fields.Many2one( 'res.company', default=lambda self: self.env.company, ) _code_per_category_unique = models.Constraint( 'unique(category_id, code, company_id)', 'Symptom code must be unique within a category.', ) @api.depends('name', 'category_id.name') def _compute_display_name(self): for r in self: r.display_name = ( f"{r.category_id.name} - {r.name}" if r.category_id else (r.name or '') )