<?xml version="1.0" encoding="UTF-8"?>
<odoo>
 <record id="action_iqi_form_list" model="ir.actions.act_window">
    <field name="name">Incoming Quality Inspection</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">sos_iqi</field>
    <field name="view_mode">tree,form</field>

</record>
<record id="sos_iqi_view_panel" model="ir.ui.view">
<field name="name">sos_iqi.search</field>
<field name="model">sos_iqi</field>
<field name="arch" type="xml">
<search position="inside">
<searchpanel>

<field name="iqi_type" string="Type" icon="fa-list" enable_counters="1"/>
<field name="from_origin" string="Received From" icon="fa-ellipsis-v" enable_counters="1"/>

</searchpanel>
<field name="iqi_no" string="IQI No"/>
 <group expand="0" string="Group By">
<filter string="Service Provider" name="service_provider_name" context="{'group_by': 'service_provider_name'}"/>
<filter string="Supplier" name="service_provider_name" context="{'group_by': 'supplier_name'}"/>

            </group>
</search>

</field>
</record>
    <record id="sos_iqi_view_tree" model="ir.ui.view">
        <field name="name">sos_iqi.view.tree</field>
        <field name="model">sos_iqi</field>
        <field name="arch" type="xml">
            <tree decoration-bf="iqi_type == 'rework'">
            <field name="iqi_type" column_invisible="1"/>
            <field name="iqi_no"/>
            <field name="iqi_date"/>
            <field name="received_qty"  decoration-primary="1"/>
            <field name="approved_qty" decoration-success="1"/>
            
            <field name="rejection_percentage_display"/>
            <field name="ppm"/>
            <field name="qc_by_name" string="QC Tested By" widget="many2one_avatar_user" optional="hide"/>
            <field name="status"  widget="badge" decoration-success="status == 'closed'" decoration-danger="status == 'open'"/>
            <field name="rejected_qty"  decoration-danger="1" optional="hide"/>
            <field name="reworked_count" optional="hide"/>
            <field name="old_iqi_ref" optional="hide"/>
            <field name="prepared_by_name" string="Prepared By" widget="many2one_avatar_user"/>

            <field name="qc_by_name" optional="hide" string="QC By" widget="many2one_avatar_user"/>
            <field name="stores_received_by" optional="hide" string="Stores Received By" widget="many2one_avatar_user"/>
            <field name="qa_by_name" optional="hide" string="QA By" widget="many2one_avatar_user"/>

<field name="write_uid" string="Last Edited By" optional="hide"/>
                <field name="write_date" string="Last Edited On" optional="hide"/>

            </tree>
        </field>
        
    </record>
       <record id="sos_iqi_form_view" model="ir.ui.view">
      <field name="name">Form</field>
        <field name="model">sos_iqi</field>
        <field name="arch" type="xml">
<form string="Model Form">
 <header>
                    <button class="btn btn-primary" type="object"
                            name="action_report_iqi_btn"><i class="fa fa-print"></i> Generate Report</button>
                   
                 
                            
                </header>

                    <sheet>
 <widget name="web_ribbon" text="Open" bg_color="bg-danger" invisible="status == 'closed'"/>
      <widget name="web_ribbon" text="Closed" bg_color="bg-success" invisible="status == 'open'"/>
      
<h2 style="text-align: center;text-transform: uppercase;text-shadow: 1px 1p 1px #140718;color: #65407c;padding:5px;">Material / SFG  <br></br>Incoming Quality Inspection</h2><hr></hr><br></br>  

<table class="table table_custom" style="box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;">
<tr><td><group><field name="material_option"/></group></td>
<td><group><field name="sfg_option"/></group></td></tr>
</table>
<br></br>
<h3 style="text-transform: uppercase;
    text-decoration: underline;">To be filled by Stores</h3>

<group>
<group>
<field name="status" invisible="1"/>
<field name="iqi_no"/>
<field name="iqi_date"/>
<field name="ir_id_unique_id"/>
</group>
<group>
<field name="in_tact"/>
<field name="test_report"/>
<field name="test_report_doc" invisible="test_report == 'no'" widget="binary" filename="test_report_filename"/>
<field name="test_report_filename" invisible="1"/>
<button name="action_view_report" invisible="not test_report_doc" string="View" type="object" class="btn-primary" icon="fa-eye"/>


</group>
</group>
<h3 style="text-transform: uppercase;
    text-decoration: underline;">To be filled by QC</h3>

<group>
<group>
<field name="inspection_label"/>
<field name="test_report_no"/>
<field name="review_test_report"/>
<field name="batch_no"/>
<field name="serial_no"/>
<field name="products"/>
<field name="fg_name"/>

</group>
<group invisible="sfg_option">

<field name="material_name"/>
<field name="material_code"/> 
<field name="supplier_name"/> 
<field name="invoice_no"/>
<field name="invoice_date"/>
<field name="received_qty"/>
<field name="uom"/>
<field name="material_category"/>
</group>
<group invisible="material_option">

<field name="sfg_name"/>
<field name="sfg_code"/> 
<field name="wo_planned_at" invisible="wo_planned_at == 'inhouse'"/> 
<field name="service_provider_name" invisible="wo_planned_at == 'inhouse'"/> 
<field name="invoice_no" invisible="wo_planned_at == 'inhouse'"/>
<field name="invoice_date" invisible="wo_planned_at == 'inhouse'"/>
<field name="received_qty"/>
<field name="uom"/>
<field name="sfg_category"/>
<field name="iqi_type" invisible="1"/>
<field name="batch_allotmnet" widget="boolean_toggle" invisible="iqi_type == 'rework'"/>
<field name="batch_allotmnet_field" readonly="1" invisible="1"/>
</group>
</group>
                     
                        
                
                             <notebook>
                             <page string="Summary Report">
                         <group>
                          <field name="received_qty"/>
                          </group>
                          <group>
                          <field name="approved_qty"/>
                          </group>
                          <group>
                          <field name="rejected_qty"/>
                          </group>
                          <group>
                          <field name="rejection_percentage_display"/>
                          </group>
                          <group>
                          <field name="ppm"/>
                          </group>
                          <group>
                          <field name="ncmr_ref" invisible="ncmr_ref == False" readonly="1"/>
                          </group>
                         </page>
                            <page string="Inspection Remarks">
                                <field name="testing_line_ids">
                                    <tree editable="bottom">
                                    <field name="qp_no"/>
                                    <field name="testing_parameter"/>
                                    <field name="req_readings"/>
                                    <field name="obtained_readings"/>
                                    <field name="inspection_remark"/>
                                    <field name="sampled_qty"/>
                                    <field name="accepted_qty"/>
                                    <field name="rejected_qty"/>
                                    <field name="aodr_qty"/>
                                    <field name="aodr_no"/>
                                    <field name="remarks"/>
                                </tree>
                                 
                                </field>

   
                            </page>
                         <page string="Monitoring &amp; Measuring Equipments">
 <field name="calibration_line_ids">
  <tree editable="bottom">
<field name="name"/>
            <field name="s_no"/>
            <field name="identification_no"/>
            <field name="certification_no"/>
            <field name="calibrated_on"/>
            <field name="calibrated_due"/>
  </tree>
                                 
</field>
                         </page>
                         <page string="Rework History">
                         <group>
                         <field name="reworked_count"/>
                         </group>
                         <group>
                         <field name="old_iqi_ref"/>
                          </group>
                         </page>
                        </notebook>
                        <templates>
    <div class="row">
<div class="col-4">
   <table class="table_custom" style="box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;">   
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>Stores Provided by Sign</b>
            <br></br><br></br>
                <button string="Approve" invisible="prepared_by_image" class="btn-primary custom_btn" type="object" name="action_report_esign_btn"></button>
            </td>
            <td><field name="prepared_by_image" widget="image"/></td>
        </tr>
        <tr invisible="prepared_by_image == False">
            <td style="padding: 8px;" class="column"><b>Prepared On</b></td>
            <td><field name="prepared_on" readonly="1"/></td>
        </tr>
        <tr invisible="prepared_by_image == False">
            <td style="padding: 8px;" class="column"><b>Prepared By</b></td>
            <td><field name="prepared_by_name" readonly="1"/></td>
        </tr>
    </table>
    </div>
    <div class="col-4">
<table class="table_custom" style="box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;">   
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>QC Tested By  </b>
            <br></br><br></br>
                <button string="Approve" invisible="qc_by_image" class="btn-primary custom_btn" type="object" name="action_qc_esign_btn"></button>
            </td>
            <td><field name="qc_by_image" widget="image"/></td>
        </tr>
        <tr invisible="qc_by_image == False">
            <td style="padding: 8px;" class="column"><b>Tested On</b></td>
            <td><field name="qc_tested_on" readonly="1"/></td>
        </tr>
        <tr invisible="qc_by_image == False">
            <td style="padding: 8px;" class="column"><b>Tested By</b></td>
            <td><field name="qc_by_name" readonly="1"/></td>
        </tr>
    </table>
     </div>
    <div class="col-4">
 <table class="table_custom" style="box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;">   
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>Stores Received By </b>
            <br></br><br></br>
                <button string="Approve" invisible="stores_received_image" class="btn-primary custom_btn" type="object" name="action_stores_received_esign_btn"></button>
            </td>
            <td><field name="stores_received_image" widget="image"/></td>
        </tr>
        <tr invisible="stores_received_image == False">
            <td style="padding: 8px;" class="column"><b>Received On</b></td>
            <td><field name="stores_received_on" readonly="1"/></td>
        </tr>
        <tr invisible="stores_received_image == False">
            <td style="padding: 8px;" class="column"><b>Received By</b></td>
            <td><field name="stores_received_by" readonly="1"/></td>
        </tr>
    </table>
     </div>
</div>
     <br></br>

    <div class="row">
    
       <div class="col-12 col-md-8 offset-md-2">

    <table class="table_custom" style="box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;">           
        <tr>
            <td style="padding: 8px;" class="column"><b>QA Comments</b></td>
            
            <td><field name="qa_comments"/></td>
        </tr>
        <tr>
            <td style="padding: 8px;" class="column"><b>RCA Required</b></td>
            
            <td><field name="rca_required"/></td>
        </tr>
        <tr>
            <td style="padding: 8px;" class="column"><b>Notes</b></td>
            
            <td><field name="rca_notes_text"/></td>
        </tr>
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>QA Approved By  </b>
            <br></br><br></br>
                <button string="Approve" invisible="qa_by_image" class="btn-primary custom_btn" type="object" name="action_qa_esign_btn"></button>
            </td>
            <td><field name="qa_by_image" widget="image"/></td>
        </tr>
        <tr invisible="qa_by_image == False">
            <td style="padding: 8px;" class="column"><b>Approved On</b></td>
            <td><field name="qa_tested_on" readonly="1"/></td>
        </tr>
        <tr invisible="qa_by_image == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="qa_by_name" readonly="1"/></td>
        </tr>
    </table>
</div>
</div>
                            </templates>

                    </sheet>
                </form>
        </field>
    </record>
<menuitem id="iqi_menu" sequence="1"
              name="Incoming Quality Inspection (IQI)"
              parent="mop_forms_menu_root" action="action_iqi_form_list" groups="sos_inventory.sos_healthcare_user,sos_inventory.sos_scg_group_manager,sos_inventory.sos_scg_group_user,sos_inventory.sos_qc_user,sos_inventory.sos_qa_user,sos_inventory.sos_management_user" />
              

</odoo>
