Files
Odoo-Modules/fusion_repairs/models/intake_answer.py
gsinghpal 429084e0bf feat(fusion_repairs): Phase 1 MVP - backend intake wizard + core models
Scaffolds the fusion_repairs module that extends Odoo 19 repair.order with
a guided medical-equipment intake workflow.

Models
- fusion.repair.product.category (8 medical equipment categories seeded)
- fusion.repair.intake.template / .question / .answer (7 templates,
  32 questions seeded across hospital bed, stairlift, porch lift,
  wheelchair, walker/rollator, mattress)
- fusion.repair.intake.service (AbstractModel) - single entry point used
  by backend wizard, sales rep portal, and public client portal so all
  three surfaces produce identical outcomes
- repair.order extensions (x_fc_intake_*, x_fc_third_party_equipment,
  x_fc_photo_ids, x_fc_urgency, x_fc_estimated/actual_cost, AI summary)
- fusion.technician.task back-link (x_fc_repair_order_id)
- res.partner service preferences (preferred tech, time window, access notes)
- res.users repair extensions (skills, cost rate, on-call rotation fields)
- res.config.settings for variance thresholds, portal URL, rate limit

UI
- Backend intake wizard with multi-equipment loop, third-party flag, photos
- repair.order form: Intake tab, Photos, Pricing tab, AI tab, smart buttons
  (technician tasks, intake answers, original SO)
- Kanban + list view urgency badges
- Fusion Repairs app menu (New Service Call, Repair Orders, Config)

Activities & Email
- 4 follow-up activity types (CS callback, tech dispatch, visit follow-up,
  manager review) with urgency-tiered deadlines
- 2 mail templates (client confirmation + office notification) with the
  same dark/light-safe styling as fusion_claims ADP templates

Security
- New res.groups.privilege + 3 groups (User, Dispatcher, Manager)
- Reuses fusion_tasks.group_field_technician (do NOT recreate)
- Reuses fusion_authorizer_portal.group_sales_rep_portal
- Multi-company global rule + technician scoping rule on repair.order

Verified end-to-end on local westin-v19 dev DB via odoo-shell - creates
multiple repairs in one session, auto-creates dispatch task for urgent,
attaches 4 activity types correctly per urgency tier and third-party flag.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-20 21:35:52 -04:00

89 lines
2.8 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2024-2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
from odoo import api, fields, models
class FusionRepairIntakeAnswer(models.Model):
"""An answer to a single intake question on a specific repair order.
Persists raw answer values for audit + reporting + AI / catalogue matching.
"""
_name = 'fusion.repair.intake.answer'
_description = 'Repair Intake Answer'
_order = 'repair_id, sequence, id'
repair_id = fields.Many2one(
'repair.order',
string='Repair Order',
required=True,
ondelete='cascade',
index=True,
)
question_id = fields.Many2one(
'fusion.repair.intake.question',
string='Question',
required=True,
ondelete='restrict',
)
question_name = fields.Char(
related='question_id.name',
string='Question',
store=True,
)
question_type = fields.Selection(
related='question_id.question_type',
store=True,
)
sequence = fields.Integer(
related='question_id.sequence',
store=True,
)
# Typed value fields - one per supported type, plus a display string.
value_char = fields.Char(string='Text Answer')
value_text = fields.Text(string='Long Text Answer')
value_selection = fields.Char(string='Choice Answer')
value_boolean = fields.Boolean(string='Yes/No Answer')
value_integer = fields.Integer(string='Number Answer')
value_date = fields.Date(string='Date Answer')
value_display = fields.Char(
string='Answer',
compute='_compute_value_display',
store=True,
)
company_id = fields.Many2one(
'res.company',
related='repair_id.company_id',
store=True,
index=True,
)
@api.depends(
'question_type',
'value_char', 'value_text', 'value_selection',
'value_boolean', 'value_integer', 'value_date',
)
def _compute_value_display(self):
for answer in self:
if answer.question_type == 'char':
answer.value_display = answer.value_char or ''
elif answer.question_type == 'text':
answer.value_display = (answer.value_text or '')[:200]
elif answer.question_type == 'selection':
answer.value_display = answer.value_selection or ''
elif answer.question_type == 'boolean':
answer.value_display = 'Yes' if answer.value_boolean else 'No'
elif answer.question_type == 'integer':
answer.value_display = str(answer.value_integer or 0)
elif answer.question_type == 'date':
answer.value_display = (
fields.Date.to_string(answer.value_date) if answer.value_date else ''
)
else:
answer.value_display = ''