<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <!-- Sequence for Assessment Reference - noupdate=1 prevents reset on module upgrade -->
    <data noupdate="1">
        <record id="seq_fusion_assessment" model="ir.sequence">
            <field name="name">Assessment Sequence</field>
            <field name="code">fusion.assessment</field>
            <field name="prefix">ASM-</field>
            <field name="padding">5</field>
            <field name="number_next">1</field>
            <field name="number_increment">1</field>
        </record>
        
        <!-- Sequence for Accessibility Assessment Reference -->
        <record id="seq_fusion_accessibility_assessment" model="ir.sequence">
            <field name="name">Accessibility Assessment Sequence</field>
            <field name="code">fusion.accessibility.assessment</field>
            <field name="prefix">ACC-</field>
            <field name="padding">5</field>
            <field name="number_next">1</field>
            <field name="number_increment">1</field>
        </record>
    </data>

    <!-- ================================================================= -->
    <!-- Email Template: Case Assigned to Authorizer                       -->
    <!-- ================================================================= -->
    <record id="mail_template_case_assigned" model="mail.template">
        <field name="name">Authorizer Portal: Case Assigned</field>
        <field name="model_id" ref="sale.model_sale_order"/>
        <field name="subject">New Case Assigned: {{ object.name }} - {{ object.partner_id.name }}</field>
        <field name="email_from">{{ (object.company_id.email or object.user_id.email or 'noreply@example.com') }}</field>
        <field name="email_to">{{ object.x_fc_authorizer_id.email }}</field>
        <field name="body_html" type="html">
<div style="font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Arial,sans-serif;max-width:600px;margin:0 auto;color:#2d3748;">
    <div style="height:4px;background-color:#2B6CB0;"></div>
    <div style="background:#ffffff;padding:32px 28px;border:1px solid #e2e8f0;border-top:none;">
        <p style="color:#2B6CB0;font-size:13px;font-weight:600;letter-spacing:0.5px;text-transform:uppercase;margin:0 0 24px 0;"><t t-out="object.company_id.name"/></p>
        <h2 style="color:#1a202c;font-size:22px;font-weight:700;margin:0 0 6px 0;">New Case Assigned</h2>
        <p style="color:#718096;font-size:15px;line-height:1.5;margin:0 0 24px 0;">A new <t t-out="dict(object.fields_get(['x_fc_sale_type'])['x_fc_sale_type']['selection']).get(object.x_fc_sale_type, 'New')" /> case has been assigned to you.</p>
        <table style="width:100%;border-collapse:collapse;margin:0 0 24px 0;">
            <tr><td colspan="2" style="padding:10px 14px;font-size:12px;font-weight:600;color:#718096;text-transform:uppercase;letter-spacing:0.5px;border-bottom:2px solid #e2e8f0;">Case Details</td></tr>
            <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;width:35%;">Case</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.name"/></td></tr>
            <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Client</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.partner_id.name"/></td></tr>
            <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Type</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="dict(object.fields_get(['x_fc_sale_type'])['x_fc_sale_type']['selection']).get(object.x_fc_sale_type, '')" /></td></tr>
            <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Date</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.date_order" t-options='{"widget": "date"}'/></td></tr>
        </table>
        <p style="text-align:center;margin:28px 0;"><a href="/my/authorizer" style="display:inline-block;background:#2B6CB0;color:#ffffff;padding:12px 28px;text-decoration:none;border-radius:6px;font-size:14px;font-weight:600;">View in Portal</a></p>
        <p style="color:#2d3748;font-size:14px;line-height:1.6;margin:24px 0 0 0;">Best regards,<br/><strong><t t-out="object.user_id.name or object.company_id.name"/></strong><br/><span style="color:#718096;"><t t-out="object.company_id.name"/></span></p>
    </div>
    <div style="padding:16px 28px;text-align:center;"><p style="color:#a0aec0;font-size:11px;margin:0;">This is an automated notification from <t t-out="object.company_id.name"/>.</p></div>
</div>
        </field>
        <field name="auto_delete" eval="False"/>
    </record>

    <!-- Status Changed template removed - redundant.
         Each workflow transition sends its own detailed email from fusion_claims.
         Record kept to avoid XML ID reference errors on upgrade. -->
    <record id="mail_template_status_changed" model="mail.template">
        <field name="name">Authorizer Portal: Status Changed (Disabled)</field>
        <field name="model_id" ref="sale.model_sale_order"/>
        <field name="subject">Case Update: {{ object.name }}</field>
        <field name="body_html" type="html"><p>This template is no longer in use.</p></field>
        <field name="auto_delete" eval="True"/>
    </record>

    <!-- ================================================================= -->
    <!-- Email Template: Assessment Complete - To Authorizer               -->
    <!-- ================================================================= -->
    <record id="mail_template_assessment_complete_authorizer" model="mail.template">
        <field name="name">Assessment Complete - Authorizer Notification</field>
        <field name="model_id" ref="model_fusion_assessment"/>
        <field name="subject">Assessment Complete: {{ object.reference }} - {{ object.client_name }}</field>
        <field name="email_from">{{ (object.sales_rep_id.company_id.email or 'noreply@example.com') }}</field>
        <field name="email_to">{{ object.authorizer_id.email }}</field>
        <field name="body_html" type="html">
<div style="font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Arial,sans-serif;max-width:600px;margin:0 auto;color:#2d3748;">
    <div style="height:4px;background-color:#38a169;"></div>
    <div style="background:#ffffff;padding:32px 28px;border:1px solid #e2e8f0;border-top:none;">
        <p style="color:#38a169;font-size:13px;font-weight:600;letter-spacing:0.5px;text-transform:uppercase;margin:0 0 24px 0;"><t t-out="object.sales_rep_id.company_id.name or object.env.company.name"/></p>
        <h2 style="color:#1a202c;font-size:22px;font-weight:700;margin:0 0 6px 0;">Assessment Complete</h2>
        <p style="color:#718096;font-size:15px;line-height:1.5;margin:0 0 24px 0;">The assessment for <strong style="color:#2d3748;"><t t-out="object.client_name"/></strong> has been completed and a sale order has been created.</p>
        <table style="width:100%;border-collapse:collapse;margin:0 0 24px 0;">
            <tr><td colspan="2" style="padding:10px 14px;font-size:12px;font-weight:600;color:#718096;text-transform:uppercase;letter-spacing:0.5px;border-bottom:2px solid #e2e8f0;">Assessment Details</td></tr>
            <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;width:35%;">Reference</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.reference"/></td></tr>
            <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Client</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.client_name"/></td></tr>
            <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Date</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.assessment_date" t-options='{"widget": "date"}'/></td></tr>
            <t t-if="object.sale_order_id">
                <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Sale Order</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.sale_order_id.name"/></td></tr>
            </t>
        </table>
        <div style="border-left:3px solid #38a169;padding:12px 16px;margin:0 0 24px 0;background:#f7fafc;">
            <p style="margin:0;font-size:14px;line-height:1.5;color:#2d3748;"><strong>Next steps:</strong> Please submit the ADP application (including pages 11-12 signed by the client) so we can proceed with the claim submission.</p>
        </div>
        <p style="text-align:center;margin:28px 0;"><a href="/my/authorizer" style="display:inline-block;background:#38a169;color:#ffffff;padding:12px 28px;text-decoration:none;border-radius:6px;font-size:14px;font-weight:600;">View in Portal</a></p>
        <p style="color:#2d3748;font-size:14px;line-height:1.6;margin:24px 0 0 0;">Best regards,<br/><strong><t t-out="object.sales_rep_id.name or 'The Team'"/></strong></p>
    </div>
    <div style="padding:16px 28px;text-align:center;"><p style="color:#a0aec0;font-size:11px;margin:0;">This is an automated notification from the ADP Claims Management System.</p></div>
</div>
        </field>
        <field name="auto_delete" eval="False"/>
    </record>

    <!-- ================================================================= -->
    <!-- Email Template: Assessment Complete - To Client                   -->
    <!-- ================================================================= -->
    <record id="mail_template_assessment_complete_client" model="mail.template">
        <field name="name">Assessment Complete - Client Notification</field>
        <field name="model_id" ref="model_fusion_assessment"/>
        <field name="subject">Your Assessment is Complete - {{ object.reference }}</field>
        <field name="email_from">{{ (object.sales_rep_id.company_id.email or 'noreply@example.com') }}</field>
        <field name="email_to">{{ object.client_email }}</field>
        <field name="body_html" type="html">
<div style="font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Arial,sans-serif;max-width:600px;margin:0 auto;color:#2d3748;">
    <div style="height:4px;background-color:#2B6CB0;"></div>
    <div style="background:#ffffff;padding:32px 28px;border:1px solid #e2e8f0;border-top:none;">
        <p style="color:#2B6CB0;font-size:13px;font-weight:600;letter-spacing:0.5px;text-transform:uppercase;margin:0 0 24px 0;"><t t-out="object.sales_rep_id.company_id.name or object.env.company.name"/></p>
        <h2 style="color:#1a202c;font-size:22px;font-weight:700;margin:0 0 6px 0;">Assessment Complete</h2>
        <p style="color:#718096;font-size:15px;line-height:1.5;margin:0 0 24px 0;">Dear <strong style="color:#2d3748;"><t t-out="object.client_name"/></strong>, thank you for completing your assessment with us.</p>
        <table style="width:100%;border-collapse:collapse;margin:0 0 24px 0;">
            <tr><td colspan="2" style="padding:10px 14px;font-size:12px;font-weight:600;color:#718096;text-transform:uppercase;letter-spacing:0.5px;border-bottom:2px solid #e2e8f0;">Summary</td></tr>
            <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;width:35%;">Reference</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.reference"/></td></tr>
            <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Date</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.assessment_date" t-options='{"widget": "date"}'/></td></tr>
            <t t-if="object.authorizer_id">
                <tr><td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Therapist</td><td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.authorizer_id.name"/></td></tr>
            </t>
        </table>
        <div style="border-left:3px solid #2B6CB0;padding:12px 16px;margin:0 0 24px 0;background:#f7fafc;">
            <p style="margin:0 0 8px 0;font-size:14px;color:#2d3748;font-weight:600;">What happens next:</p>
            <ol style="margin:0;padding-left:20px;font-size:14px;line-height:1.6;color:#2d3748;">
                <li>Your assessment will be reviewed by our team</li>
                <li>We will submit the ADP application on your behalf</li>
                <li>You will be notified once approval is received</li>
                <li>Your equipment will be ordered and delivered</li>
            </ol>
        </div>
        <p style="color:#2d3748;font-size:14px;line-height:1.5;">If you have any questions, please do not hesitate to contact us.</p>
        <p style="color:#2d3748;font-size:14px;line-height:1.6;margin:24px 0 0 0;">Best regards,<br/><strong><t t-out="object.sales_rep_id.name or 'The Team'"/></strong></p>
    </div>
    <div style="padding:16px 28px;text-align:center;"><p style="color:#a0aec0;font-size:11px;margin:0;">This is an automated notification from the ADP Claims Management System.</p></div>
</div>
        </field>
        <field name="auto_delete" eval="False"/>
    </record>

    <!-- ================================================================= -->
    <!-- Email Template: Document Uploaded                                 -->
    <!-- ================================================================= -->
    <record id="mail_template_document_uploaded" model="mail.template">
        <field name="name">Authorizer Portal: Document Uploaded</field>
        <field name="model_id" ref="sale.model_sale_order"/>
        <field name="subject">New Document Uploaded: {{ object.name }}</field>
        <field name="email_from">{{ (object.company_id.email or 'noreply@example.com') }}</field>
        <field name="email_to">{{ object.x_fc_authorizer_id.email }}</field>
        <field name="body_html" type="html">
<div style="font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Arial,sans-serif;max-width:600px;margin:0 auto;color:#2d3748;">
    <div style="height:4px;background-color:#2B6CB0;"></div>
    <div style="background:#ffffff;padding:32px 28px;border:1px solid #e2e8f0;border-top:none;">
        <p style="color:#2B6CB0;font-size:13px;font-weight:600;letter-spacing:0.5px;text-transform:uppercase;margin:0 0 24px 0;"><t t-out="object.company_id.name"/></p>
        <h2 style="color:#1a202c;font-size:22px;font-weight:700;margin:0 0 6px 0;">New Document Available</h2>
        <p style="color:#718096;font-size:15px;line-height:1.5;margin:0 0 24px 0;">A new document has been uploaded for case <strong style="color:#2d3748;"><t t-out="object.name"/></strong> (<t t-out="object.partner_id.name"/>).</p>
        <p style="text-align:center;margin:28px 0;"><a href="/my/authorizer" style="display:inline-block;background:#2B6CB0;color:#ffffff;padding:12px 28px;text-decoration:none;border-radius:6px;font-size:14px;font-weight:600;">View in Portal</a></p>
        <p style="color:#2d3748;font-size:14px;line-height:1.6;margin:24px 0 0 0;">Best regards,<br/><strong><t t-out="object.company_id.name"/></strong></p>
    </div>
    <div style="padding:16px 28px;text-align:center;"><p style="color:#a0aec0;font-size:11px;margin:0;">This is an automated notification from <t t-out="object.company_id.name"/>.</p></div>
</div>
        </field>
        <field name="auto_delete" eval="False"/>
    </record>

</odoo>
