# -*- coding: utf-8 -*- # Copyright 2024-2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) from odoo import fields, models QUESTION_TYPES = [ ('char', 'Short Text'), ('text', 'Long Text'), ('selection', 'Single Choice'), ('boolean', 'Yes / No'), ('integer', 'Number'), ('date', 'Date'), ] class FusionRepairIntakeQuestion(models.Model): """A single question on an intake template. Supports basic conditional display: a question is only shown when the parent question's answer matches `parent_answer_value`. The wizard and portal forms render based on these rules. """ _name = 'fusion.repair.intake.question' _description = 'Repair Intake Question' _order = 'sequence, id' template_id = fields.Many2one( 'fusion.repair.intake.template', string='Template', required=True, ondelete='cascade', index=True, ) sequence = fields.Integer(string='Sequence', default=10) name = fields.Char( string='Question', required=True, translate=True, help='Text shown to the user.', ) code = fields.Char( string='Code', help='Stable identifier for this question (used by automation rules and reporting).', ) help_text = fields.Char( string='Help Text', translate=True, help='Optional shorter hint shown beneath the question (e.g. "e.g. SN-12345").', ) question_type = fields.Selection( QUESTION_TYPES, string='Type', required=True, default='char', ) required = fields.Boolean(default=False) selection_options = fields.Text( string='Choices', help='One option per line, only used when type is "Single Choice".', ) # Conditional display parent_question_id = fields.Many2one( 'fusion.repair.intake.question', string='Show Only If Question', domain="[('template_id', '=', template_id), ('id', '!=', id)]", ondelete='set null', help='Show this question only when the parent question matches the value below.', ) parent_answer_value = fields.Char( string='Parent Answer Equals', help='Value the parent answer must equal for this question to be displayed.', ) # Symptom keyword classification - feeds the service catalogue matcher and AI prompt symptom_keywords = fields.Char( string='Symptom Keywords', help='Comma-separated keywords that, when present in the answer, tag the repair ' 'for catalogue matching (e.g. "battery,charge").', )