<odoo>
    <record id="action_report_dock_audit" model="ir.actions.report">
        <field name="name">Dock Audit Form</field>
        <field name="model">sos_dock_audit</field>
        <field name="report_type">qweb-pdf</field>
        <field name="report_name">sos_inventory.report_dock_audit</field>
        <field name="report_file">sos_inventory.report_dock_audit</field>
        <field name="binding_model_id" eval="False"/>
        <field name="binding_type">report</field>
    </record>

<template id="report_dock_audit">
    <t t-call="web.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="web.external_layout">
             <link rel="stylesheet" href="/sos_inventory/static/src/css/style.css" />
                <div class="page">
            
                    <h3 style="text-align:center">Dock Audit</h3>
                    <br></br>
                    
                    <table class="table">
                     <t t-if="o.deliverables_boq_id.sales_id.order_id">
                    <tr><td class="column">Order Id</td><td colspan="3"><t t-esc="o.deliverables_boq_id.sales_id.order_id"/></td></tr>
                    </t>
                    <tr><td class="column">Dock Audit No</td><td><t t-esc="o.dock_audit_no"/></td><td class="column">Customer</td><td><t t-esc="o.customer_name"/></td></tr>

                    <tr><td class="column">PO No</td><td><t t-esc="o.customer_po_no"/></td><td class="column">Quantity</td><td><t t-esc="o.quantity"/></td></tr>
                    <tr><td class="column">Lead Time</td><td><t t-esc="o.lead_time"/></td><td class="column">FG Name</td><td><t t-esc="o.fg_name"/></td></tr>
                    </table>
                     <br></br>
                      <table class="table">
                <tbody>  
 <tr><td colspan="9" style="background-color:#ddd;font-weight:bold">Accessories List</td></tr>
  
             <tr class="column">
    <td class="column">S.No</td>
    <td class="column">Accessory</td>
    <td class="column">UOM</td>
    <td class="column">Yes</td>
    <td class="column">No</td>
    <td class="column">NA</td>
    <td class="column">Qty</td>
    <td class="column">Remarks</td>
    <td class="column">Phase</td>

</tr>  
<t t-set="counter" t-value="0"/>
<!-- <t t-set="current_phase" t-value="o.report_phase"/> -->
<t t-set="current_phase" t-value="o.env.context.get('report_phase')"/>
<!-- <p><b>Current Report Phase:</b> <t t-esc="str(o.env.context.get('report_phase'))"/></p> --> <!-- print current_phase -->
<t t-foreach="o.line_ids_fg" t-as="line_items">
<!-- <p><b>Line Items Phase:</b> <t t-esc="str(line_items.phase)"/></p> -->

<t t-set="target" t-value="'P%s-' % current_phase"/>
<t t-if="target in line_items.total_phase_count">

<!-- <t t-if="current_phase in line_items.phase"> -->
<!-- <t t-if="not current_phase or current_phase in line_items.phase"> -->
<!-- <t t-if="line_items.phase == current_phase"> -->
<tr>
 <t t-set="counter" t-value="counter + 1"/>
<td><t t-esc="counter"/></td>
<td><t t-esc="line_items.component_id.name"/></td>
<td><t t-esc="line_items.uom"/></td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<td>
<!-- <t t-esc="line_items.total_phase_count"/> -->

<!-- Split and loop through total_phase_count -->
    <t t-foreach="line_items.total_phase_count.split(',')" t-as="item">
        <t t-if="item.startswith(target)">
        <t t-esc="item"/>
        </t>
    </t>
</td>
</tr>
</t>

<!-- Else Code added -->

<t t-else="">
<t t-if="current_phase == 'all'">
<tr>
<t t-set="counter" t-value="counter + 1"/>
<td><t t-esc="counter"/></td>
<td><t t-esc="line_items.component_id.name"/></td>
<td><t t-esc="line_items.uom"/></td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<td><t t-esc="line_items.total_phase_count"/></td>


</tr>
</t>
</t>

<!-- End -->

</t>
<t t-foreach="o.line_ids_sfg" t-as="line_items">

<t t-set="target" t-value="'P%s-' % current_phase"/>
<t t-if="target in line_items.total_phase_count">

<!-- <t t-if="current_phase in line_items.phase"> -->
<!-- <t t-if="line_items.phase == current_phase"> -->
<tr>
<t t-set="counter" t-value="counter + 1"/>
<td><t t-esc="counter"/></td>
<td><t t-esc="line_items.component_id.name"/></td>
<td><t t-esc="line_items.uom"/></td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<td>
    <!-- <t t-esc="line_items.total_phase_count"/> -->
    <t t-foreach="line_items.total_phase_count.split(',')" t-as="item">
        <t t-if="item.startswith(target)">
        <t t-esc="item"/>
        </t>
    </t>
</td>
</tr>
</t>

<!-- Else Code added -->

<t t-else="">
<t t-if="current_phase == 'all'">
<tr>
<t t-set="counter" t-value="counter + 1"/>
<td><t t-esc="counter"/></td>
<td><t t-esc="line_items.component_id.name"/></td>
<td><t t-esc="line_items.uom"/></td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<td><t t-esc="line_items.total_phase_count"/></td>
</tr>
</t>
</t>
<!-- End -->
</t>

<t t-foreach="o.line_ids_material" t-as="line_items">
<!-- <t t-if="line_items.phase == current_phase"> -->
<!-- <t t-if="current_phase in line_items.phase"> -->

<t t-set="target" t-value="'P%s-' % current_phase"/>
<t t-if="target in line_items.total_phase_count">

<tr>
<t t-set="counter" t-value="counter + 1"/>
<td><t t-esc="counter"/></td>
<td><t t-esc="line_items.component_id.part_no"/></td>
<td><t t-esc="line_items.uom"/></td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<td>
<!-- <t t-esc="line_items.total_phase_count"/> -->
    <t t-foreach="line_items.total_phase_count.split(',')" t-as="item">
        <t t-if="item.startswith(target)">
        <t t-esc="item"/>
        </t>
    </t>

</td>
</tr>
</t>

<!-- Else Code added -->
<t t-else="">
 <t t-if="current_phase == 'all'">
<tr>
<t t-set="counter" t-value="counter + 1"/>
<td><t t-esc="counter"/></td>
<td><t t-esc="line_items.component_id.part_no"/></td>
<td><t t-esc="line_items.uom"/></td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<td><t t-esc="line_items.total_phase_count"/></td>
</tr>
</t>
</t>
<!-- End -->

</t>
<t t-foreach="o.line_ids_miscellaneous" t-as="line_items">
<!-- <t t-if="line_items.phase == current_phase"> -->
<t t-if="current_phase in line_items.phase">
<tr>
<t t-set="counter" t-value="counter + 1"/>
<td><t t-esc="counter"/></td>
<td><t t-esc="line_items.name"/></td>
<td>Nos</td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<!-- <td><t t-esc="line_items.total_phase_count"/></td> -->
</tr>
</t>

<!-- Else Code added -->

<t t-else="">
<t t-if="current_phase == 'all'">
<tr>
<t t-set="counter" t-value="counter + 1"/>
<td><t t-esc="counter"/></td>
<td><t t-esc="line_items.name"/></td>
<td>Nos</td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<!-- <td><t t-esc="line_items.total_phase_count"/></td> -->
</tr>
</t>
</t>

<!--End-->

</t>

<t t-if="len(o.line_ids_installation_kit) > 0">
 <tr><td colspan="9" style="background-color:#ddd;font-weight:bold">Installation Kit</td></tr>
              <tr class="column">
    <td class="column">S.No</td>
    <td class="column">Item</td>
    <td class="column">UOM</td>
    <td class="column">Yes</td>
    <td class="column">No</td>
    <td class="column">NA</td>
    <td class="column">Qty</td>
    <td class="column">Remarks</td>

</tr> 
<t t-foreach="o.line_ids_installation_kit" t-as="line_items">
<!-- <t t-if="current_phase in line_items.phase"> -->
<t t-set="target" t-value="'P%s-' % current_phase"/>
<t t-if="target in line_items.total_phase_count">
<tr>
<td><t t-esc="line_items_index + 1"/></td>
<td><t t-esc="line_items.component_id.part_no"/></td>
<td><t t-esc="line_items.uom"/></td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<td>
    <t t-foreach="line_items.total_phase_count.split(',')" t-as="item">
        <t t-if="item.startswith(target)">
        <t t-esc="item"/>
        </t>
    </t>
    <!-- <t t-esc="line_items.total_phase_count"/> -->
</td>
</tr>
</t>

<!-- Else Code added -->

<t t-else="">
<t t-if="current_phase == 'all'">
<tr>
<td><t t-esc="line_items_index + 1"/></td>
<td><t t-esc="line_items.component_id.part_no"/></td>
<td><t t-esc="line_items.uom"/></td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td><t t-esc="line_items.quantity"/></td>
<td></td>
<td><t t-esc="line_items.total_phase_count"/></td>
</tr>
</t>
</t>


<!-- End -->
</t>
</t>
 <tr><td colspan="9" style="background-color:#ddd;font-weight:bold">Design Verification</td></tr>
              <tr class="column">
    <td class="column">S.No</td>
    <td class="column">Item</td>
    <td class="column">UOM</td>
    <td class="column">Yes</td>
    <td class="column">No</td>
    <td class="column">NA</td>
    <td class="column">Qty</td>
    <td class="column">Remarks</td>

</tr> 
 <t t-foreach="o.design_verification_ids" t-as="line_items">
<tr>
<td><t t-esc="line_items_index + 1"/></td>
<td><t t-esc="line_items.name"/></td>
<td>Nos</td>
<td><input type="checkbox" checked="checked"/></td>
<td><input type="checkbox"/></td>
<td><input type="checkbox"/></td>
<td>NA</td>
<td>
    <t t-if="line_items.remarks">
        <t t-foreach="line_items.remarks.split('\n')" t-as="line">
            <t t-esc="line"/><br/>
        </t>
    </t>
</td>

</tr>
</t>

 <tr><td colspan="9" style="background-color:#ddd;font-weight:bold">QC Status</td></tr>
<tr class="column">
<td class="column">S.No</td>
<td class="column">Item</td>
<td class="column">UOM</td>
<td class="column">Yes</td>
<td class="column">No</td>
<td class="column">NA</td>
<td class="column">Qty</td>
<td class="column">Remarks</td>
</tr> 
<tr>
<td>1</td>
<td>Test Report</td>
<td>Nos</td>
 <td>
        <input type="checkbox" t-att-checked="o.test_report == 'yes'"/>
    </td>
    <td>
        <input type="checkbox" t-att-checked="o.test_report == 'no'"/>
    </td>
<td><input type="checkbox" t-att-checked="o.test_report == 'na'"/></td>
<td>NA</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>SD Card Data</td>
<td>Nos</td>
 <td>
        <input type="checkbox" t-att-checked="o.sdcard_data == 'yes'"/>
    </td>
    <td>
        <input type="checkbox" t-att-checked="o.sdcard_data == 'no'"/>
    </td>
<td><input type="checkbox" t-att-checked="o.sdcard_data == 'na'"/></td>
<td>NA</td>
<td></td>
</tr>
<tr>
<td>3</td>
<td>Cloud Data</td>
<td>Nos</td>
 <td>
        <input type="checkbox" t-att-checked="o.cloud_data == 'yes'"/>
    </td>
    <td>
        <input type="checkbox" t-att-checked="o.cloud_data == 'no'"/>
    </td>
<td><input type="checkbox" t-att-checked="o.cloud_data == 'na'"/></td>
<td>NA</td>
<td></td>
</tr>
 <tr><td colspan="9" style="background-color:#ddd;font-weight:bold">Commercial Status</td></tr>
 <tr class="column">
<td class="column">S.No</td>
<td class="column">Item</td>
<td class="column">UOM</td>
<td class="column">Yes</td>
<td class="column">No</td>
<td class="column">NA</td>
<td class="column">Qty</td>
<td class="column">Remarks</td>
</tr> 
 <tr>
<td>1</td>
<td>Payment Status</td>
<td>NA</td>
<td>
<input type="checkbox"/>
</td>
<td>
<input type="checkbox"/>
</td>
<td>
<input type="checkbox"/>
</td>
<td>NA</td>
<td><t t-esc="o.payment_status"/></td>
</tr>
  <tr>
<td>2</td>
<td>GST No</td>
<td>NA</td>
<td>
<input type="checkbox"/>
</td>
<td>
<input type="checkbox"/>
</td>
<td>
<input type="checkbox"/>
</td>
<td>NA</td>
<td><t t-esc="o.gst_no"/></td>
</tr>
 <tr>
<td>3</td>
<td>Billing Address</td>
<td>NA</td>
<td>
<input type="checkbox"/>
</td>
<td>
<input type="checkbox"/>
</td>
<td>
<input type="checkbox"/>
</td>
<td>NA</td>
<td><t t-if="o.billing_address">
                    <t t-foreach="o.billing_address.split(',')" t-as="part">
                        <t t-esc="part"/><br/>
                    </t>
                </t></td>
</tr>
 <tr>
<td>4</td>
<td>Shipping Address</td>
<td>NA</td>
<td>
<input type="checkbox"/>
</td>
<td>
<input type="checkbox"/>
</td>
<td>
<input type="checkbox"/>
</td>
<td>NA</td>
<td><t t-if="o.shipping_address">
                    <t t-foreach="o.shipping_address.split(',')" t-as="part">
                        <t t-esc="part"/><br/>
                    </t>
                </t></td>
</tr>
 <tr><td colspan="9" style="background-color:#ddd;font-weight:bold">Installation Guidelines</td></tr>
  <tr class="column">
<td class="column">S.No</td>
<td class="column">Item</td>
<td class="column">UOM</td>
<td class="column">Yes</td>
<td class="column">No</td>
<td class="column">NA</td>
<td class="column">Qty</td>
<td class="column">Remarks</td>
</tr>
 <tr>
<td>1</td>
<td>User Manual</td>
<td>NA</td>
<td>
<input type="checkbox" t-att-checked="o.user_manual == 'yes'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.user_manual == 'no'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.user_manual == 'na'"/>

</td>
<td>NA</td>
<td></td>
</tr>
 <tr>
<td>2</td>
<td>Installation Video</td>
<td>NA</td>
<td>
<input type="checkbox" t-att-checked="o.installation_video == 'yes'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.installation_video == 'no'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.installation_video == 'na'"/>

</td>
<td>NA</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>Wiring Diagram</td>
<td>NA</td>
<td>
<input type="checkbox" t-att-checked="o.wiring_diagram == 'yes'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.wiring_diagram == 'no'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.wiring_diagram == 'na'"/>

</td>
<td>NA</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>Warranty Card</td>
<td>NA</td>
<td>
<input type="checkbox" t-att-checked="o.warranty_card == 'yes'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.warranty_card == 'no'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.warranty_card == 'na'"/>

</td>
<td>NA</td>
<td></td>
</tr>
 <tr><td colspan="9" style="background-color:#ddd;font-weight:bold">Packing Status</td></tr>
  <tr class="column">
<td class="column">S.No</td>
<td class="column">Item</td>
<td class="column">UOM</td>
<td class="column">Yes</td>
<td class="column">No</td>
<td class="column">NA</td>
<td class="column">Qty</td>
<td class="column">Remarks</td>
</tr> 
 <tr>
<td>1</td>
<td>Is the Product Correct?</td>
<td>NA</td>
<td>
<input type="checkbox" t-att-checked="o.correct_product == 'yes'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.correct_product == 'no'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.correct_product == 'na'"/>
</td>
<td>NA</td>
<td></td>
</tr>
 <tr>
<td>2</td>
<td>Is the Packaging Correct?</td>
<td>NA</td>
<td>
<input type="checkbox" t-att-checked="o.packaging_correct == 'yes'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.packaging_correct == 'no'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.packaging_correct == 'na'"/>
</td>
<td>NA</td>
<td></td>
</tr>
 <tr>
<td>3</td>
<td>Is the Labeling Correct?</td>
<td>NA</td>
<td>
<input type="checkbox" t-att-checked="o.labeling_correct == 'yes'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.labeling_correct == 'no'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.labeling_correct == 'na'"/>
</td>
<td>NA</td>
<td></td>
</tr>
<tr>
<td>4</td>
<td>Internal Rework  (If Issued)</td>
<td>NA</td>
<td>
<input type="checkbox" t-att-checked="o.internal_rework == 'yes'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.internal_rework == 'no'"/>
</td>
<td>
<input type="checkbox" t-att-checked="o.internal_rework == 'na'"/>
</td>
<td>NA</td>
<td></td>
</tr>

</tbody>
</table>
<br></br>

<div style="page-break-after: always;">
</div>

  <div style="width: 100%; display: flex; justify-content: space-between; margin-top: 50px;">

    <table class="table table-bordered">

        <tr style="background-color:#ccc">
            <td style="padding: 8px;" class="column"><b>Department </b></td>
            <td style="padding: 8px;" class="column"><b>Authorized Signatory </b></td>
            <td style="padding: 8px;" class="column"><b>Authorized On</b></td>
            <td style="padding: 8px;" class="column"><b>Authorized By</b></td>
        </tr>
        <tr>
            <td>Auditor</td>
            <td><img style="height:80px;width:100px" t-if="o.audited_by_image" t-att-src="'data:image/png;base64,%s' % (o.audited_by_image.decode())" alt="Audited By"/></td>
            <td><t t-esc="o.audited_on"/></td>
            <td><t t-esc="o.audited_by_name.name"/></td>
        </tr>
        <tr>
        <td>QA</td>
            <td><img style="height:80px;width:100px" t-if="o.qa_by_image" t-att-src="'data:image/png;base64,%s' % (o.qa_by_image.decode())" alt="Tested By"/></td>

            <td><t t-esc="o.qa_tested_on"/></td>
             <td><t t-esc="o.qa_by_name.name"/></td>
        </tr>
         <tr>
        <td>CE</td>
            <td><img style="height:80px;width:100px" t-if="o.ce_image" t-att-src="'data:image/png;base64,%s' % (o.ce_image.decode())" alt="Approved By"/></td>

            <td><t t-esc="o.ce_approved_on"/></td>
             <td><t t-esc="o.ce_name.name"/></td>
        </tr>
       <tr>
        <td>Top Management</td>
            <td><img style="height:80px;width:100px" t-if="o.top_management_approval_image" t-att-src="'data:image/png;base64,%s' % (o.top_management_approval_image.decode())" alt="Approved By"/></td>

            <td><t t-esc="o.top_management_approved_on"/></td>
            <td><t t-esc="o.top_management_name.name"/></td>
        </tr>
    </table>

</div>
                </div>
            </t>
        </t>
    </t>
</template>

</odoo>