survey_custom_certificate_t.../wizards/survey_custom_certificate_wizard_views.xml
2025-11-29 08:46:04 +07:00

202 lines
12 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Placeholder List View for Wizard -->
<record id="view_survey_certificate_placeholder_tree" model="ir.ui.view">
<field name="name">survey.certificate.placeholder.list</field>
<field name="model">survey.certificate.placeholder</field>
<field name="arch" type="xml">
<list string="Placeholder Mappings" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="source_key" string="Source" readonly="1"/>
<field name="value_type" string="Value"/>
<field name="value_field" string="Field"
invisible="value_type == 'custom_text'"
required="value_type != 'custom_text'"/>
<field name="custom_text" string="Text"
invisible="value_type != 'custom_text'"
required="value_type == 'custom_text'"/>
</list>
</field>
</record>
<!-- Wizard Form View -->
<record id="view_survey_custom_certificate_wizard_form" model="ir.ui.view">
<field name="name">survey.custom.certificate.wizard.form</field>
<field name="model">survey.custom.certificate.wizard</field>
<field name="arch" type="xml">
<form string="Custom Certificate Configuration">
<header>
<!-- Progress indicator -->
<div class="o_form_statusbar" invisible="not template_file">
<div class="o_statusbar_status">
<button type="object" class="btn btn-link" disabled="1">
<span class="badge badge-pill"
style="background-color: #28a745; color: white;">
✓ Template Uploaded
</span>
</button>
<button type="object" class="btn btn-link" disabled="1">
<span class="badge badge-pill"
invisible="not placeholder_ids"
style="background-color: #28a745; color: white;">
✓ Placeholders Detected
</span>
<span class="badge badge-pill"
invisible="placeholder_ids"
style="background-color: #6c757d; color: white;">
○ Placeholders Pending
</span>
</button>
<button type="object" class="btn btn-link" disabled="1">
<span class="badge badge-pill"
invisible="not preview_pdf"
style="background-color: #28a745; color: white;">
✓ Preview Generated
</span>
<span class="badge badge-pill"
invisible="preview_pdf"
style="background-color: #6c757d; color: white;">
○ Preview Pending
</span>
</button>
</div>
</div>
</header>
<sheet>
<group>
<group>
<field name="survey_id" invisible="1"/>
<field name="template_filename" invisible="1"/>
<field name="is_update" invisible="1"/>
</group>
</group>
<!-- Update notification -->
<div class="alert alert-info" role="alert" invisible="not is_update">
<i class="fa fa-info-circle"/> <strong>Updating Existing Template</strong><br/>
Existing placeholder mappings will be preserved where placeholders match.
</div>
<!-- File Upload Section -->
<group string="📄 Step 1: Upload Certificate Template">
<div class="text-muted small mb-2" colspan="2">
Upload a Microsoft Word (.docx) file with placeholders in the format <code>{key.field_name}</code>.<br/>
<strong>Examples:</strong> <code>{key.name}</code>, <code>{key.course_name}</code>, <code>{key.date}</code><br/>
<strong>Maximum file size:</strong> 10MB
</div>
<field name="template_file"
filename="template_filename"
widget="binary"
string="Select DOCX File"
class="oe_inline"/>
<button name="action_upload_template"
string="📤 Parse Template"
type="object"
class="btn-primary oe_highlight"
invisible="not template_file"
confirm="This will analyze your template and extract all placeholders. Continue?"/>
</group>
<!-- Placeholder Mapping Section -->
<group string="🔧 Step 2: Configure Placeholder Mappings"
invisible="not placeholder_ids">
<div class="alert alert-success" role="alert" colspan="2">
<i class="fa fa-check-circle"/> <strong>Success!</strong> Found <field name="placeholder_ids" readonly="1" nolabel="1" widget="statinfo" string="Placeholders"/> placeholder(s) in your template.
</div>
<div class="text-muted small mb-2" colspan="2">
<strong>Configure how each placeholder should be filled:</strong><br/>
• The system has automatically suggested mappings for recognized placeholder names<br/>
• You can change the <strong>Value</strong> type and <strong>Field</strong> for each placeholder<br/>
• Drag rows to reorder placeholders
</div>
<field name="placeholder_ids" nolabel="1" colspan="2">
<list string="Placeholder Mappings" editable="bottom" decoration-info="value_type == 'custom_text'">
<field name="sequence" widget="handle"/>
<field name="source_key" string="📍 Placeholder" readonly="1"/>
<field name="value_type" string="🔄 Value Type"/>
<field name="value_field" string="📊 Data Field"
invisible="value_type == 'custom_text'"
required="value_type != 'custom_text'"
placeholder="e.g., survey_title, partner_name"/>
<field name="custom_text" string="✏️ Custom Text"
invisible="value_type != 'custom_text'"
required="value_type == 'custom_text'"
placeholder="Enter static text for all certificates"/>
</list>
</field>
<div class="alert alert-warning" role="alert" colspan="2">
<i class="fa fa-lightbulb-o"/> <strong>Tip:</strong> Generate a preview to verify your configuration before saving.
</div>
<button name="action_generate_preview"
string="👁️ Generate Preview"
type="object"
class="btn-secondary oe_highlight"
invisible="not placeholder_ids"
confirm="This will generate a sample certificate with test data. This may take a few moments. Continue?"/>
</group>
<!-- Preview Section -->
<group string="👁️ Step 3: Preview Certificate"
invisible="not preview_pdf">
<div class="alert alert-success" role="alert" colspan="2">
<i class="fa fa-check-circle"/> <strong>Preview Generated Successfully!</strong><br/>
Review the certificate below to verify that all placeholders are correctly replaced and formatting is preserved.
</div>
<field name="preview_pdf"
widget="pdf_viewer"
nolabel="1"
colspan="2"/>
<div class="text-muted small mt-2" colspan="2">
<i class="fa fa-info-circle"/> This preview uses sample data. Actual certificates will use real participant information.
</div>
</group>
<!-- Help Section -->
<group string="❓ Need Help?" invisible="placeholder_ids">
<div class="alert alert-info" role="alert" colspan="2">
<strong>Getting Started:</strong><br/>
1. Upload a DOCX template with placeholders like <code>{key.name}</code><br/>
2. Click "Parse Template" to extract placeholders<br/>
3. Configure how each placeholder should be filled<br/>
4. Generate a preview to verify your configuration<br/>
5. Click "Save" to apply the template to your survey<br/><br/>
<a href="/web#action=survey_custom_certificate_template.action_view_user_guide" target="_blank">
📖 View Full Documentation
</a>
</div>
</group>
</sheet>
<!-- Footer Buttons -->
<footer>
<button name="action_save_template"
string="💾 Save Configuration"
type="object"
class="btn-primary oe_highlight"
invisible="not placeholder_ids"
confirm="This will save the template and mappings to your survey. Certificates will be generated using this configuration. Continue?"/>
<button string="❌ Cancel"
class="btn-secondary"
special="cancel"/>
<div class="text-muted small float-right" invisible="not placeholder_ids">
<i class="fa fa-info-circle"/> Changes will be applied to the survey after clicking Save
</div>
</footer>
</form>
</field>
</record>
<!-- Wizard Action Definition -->
<record id="action_survey_custom_certificate_wizard" model="ir.actions.act_window">
<field name="name">Configure Custom Certificate</field>
<field name="res_model">survey.custom.certificate.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="survey.model_survey_survey"/>
</record>
</odoo>