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


 <record id="action_ncmr_form_list" model="ir.actions.act_window">
    <field name="name">NON-CONFORMING MATERIAL REPORT</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">sos_ncmr</field>
    <field name="view_mode">tree,form,kanban</field>

</record>

    <record id="sos_ncmr_view_tree" model="ir.ui.view">
        <field name="name">sos_ncmr.view.tree</field>
        <field name="model">sos_ncmr</field>
        <field name="arch" type="xml">
            <tree>
                <header>
      <button name="%(action_ncmr_wizard)d" string="Report" type="action" class="oe_highlight" display="always"/>
   </header>  
                <field name="ncmr_no"/>
                 <field name="ncmr_date"/>
                 <field name="combined_incoming_doc_ref"/>
                 <field name="opened_issues" optional="hide"/>
                 <field name="closed_issues" optional="hide"/>
                  <field name="qa_by" string="QC Approval" widget="many2one_avatar_user"/>
                  <field name="scg_approval_by" string="SCG Approval" widget="many2one_avatar_user"/>
                  <field name="production_approval_by" string="Production Approval" widget="many2one_avatar_user"/>
                  <field name="forward_by" string="QA Approval" widget="many2one_avatar_user"/>

                 <field name="status"  widget="badge" decoration-success="status == 'closed'" decoration-danger="status == 'open'"/>
<field name="rework_action_by_qc"  widget="boolean_toggle"/>
                 <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_ncmr_form_view" model="ir.ui.view">
      <field name="name">Form</field>
        <field name="model">sos_ncmr</field>
        <field name="arch" type="xml">
  <form string="Model Form">
                              <header>
                    <button class="btn btn-primary" type="object"
                            name="action_report_ncmr_btn"><i class="fa fa-print"></i> Print</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;">Non-Conforming Material Report</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>
<td><group><field name="fg_option"/></group></td></tr>

</table>
<br></br>
                        <!-- Topmost Group -->
                <group>
                <!-- First Column -->
                <group>
                <field name="rca_required" invisible="1"/>
                <field name="status" invisible="1"/>
                <field name="department"/>
                <field name="ncmr_no"/>
<field name="ncmr_type" invisible="1"/>
                <field name="ncmr_date"/>
            <field name="outsourcing_return_ref_no" invisible="rework_action  == 'inhouse'"/>
                </group>
                <!-- Second Column -->
                <group>
  
    
                <field name="fg_name"/>
                  <field name="fg_category" invisible="1"/>
  <field name="customer_name" invisible="customer_name == False"/>

                <field name="batch_no"/>
<field name="rejected_qty" invisible="fg_option != True"/>
                </group>
                </group>
                <group invisible="material_option != True">
 <field name="material_code"/>
  <field name="material_name"/>
  <field name="material_category"/>
  <field name="supplier_name" invisible="supplier_name == False"/>

  <field name="rejected_qty"/>

                </group>
                <group invisible="sfg_option != True">
 <field name="sfg_code"/>
  <field name="sfg_name"/>
  <field name="sfg_category"/>
    <field name="service_provider_name" invisible="service_provider_name == False"/>

  <field name="rejected_qty"/>


                </group>

<br></br>
<group>                
<field name="rca_notes_text" invisible="not rca_notes_text" readonly="1" style="background-color: #eed4f1;padding: 20px;
    border-radius: 5px;margin-bottom: 20px;"/>
</group>
       <notebook>
        <page string="Defective Details"  invisible="fg_option != True">
        
         <field name="line_ids">
         <tree editable="bottom">
        <field name="s_no"/>
        <field name="fg_defectives_domain" column_invisible="1"/>
        <field name="fg_defectives"  options="{'no_quick_create': True}" widget="many2many_tags" domain="[('id', 'in', fg_defectives_domain)]" />

         <field name="remarks"/>
        <field name="fg_defective_count"/>
        </tree>
        </field>
        <group class="oe_subtotal_footer oe_right">
<label for="fg_line_count"/><field name="fg_line_count" nolabel="1" readonly="True"/>
<label for="fg_unique_defect_count"/><field name="fg_unique_defect_count" nolabel="1" readonly="True"/>
                            </group>
       </page>
        <page string="Defective Details"  invisible="sfg_option != True">
        
         <field name="line_ids">
         <tree editable="bottom">
        <field name="s_no"/>
  
        <field name="defectives_domain" column_invisible="1"/>
        <field name="defectives"  options="{'no_quick_create': True}" widget="many2many_tags" domain="[('id', 'in', defectives_domain)]" />

         <field name="remarks"/>
        <field name="defective_count"/>
        </tree>
        </field>
        <group class="oe_subtotal_footer oe_right">
<label for="line_count"/><field name="line_count" nolabel="1" readonly="True"/>
<label for="unique_defect_count"/><field name="unique_defect_count" nolabel="1" readonly="True"/>
                            </group>
       </page>
               <page string="Defective Details"  invisible="material_option != True">
        
         <field name="line_ids">
         <tree editable="bottom">
        <field name="s_no"/>
  
<field name="material_defectives_domain"  column_invisible="1"/>
        <field name="material_defectives" options="{'no_quick_create': True}" widget="many2many_tags" domain="[('id', 'in', material_defectives_domain)]" />
        <field name="remarks"/>
        <field name="material_defective_count"/>
        </tree>
        </field>
        <group class="oe_subtotal_footer oe_right">
<label for="material_line_count"/><field name="material_line_count" nolabel="1" readonly="True"/>
<label for="material_unique_defect_count"/><field name="material_unique_defect_count" nolabel="1" readonly="True"/>
                            </group>
       </page>
       <page string="Document Reference">
       <table class="table table-bordered">
<thead>
<tr>

<th class="column">Source</th>
<th class="column">Document Reference</th>
<th class="column">Responsible Member Name, Designation and Department / Process to attend</th>

</tr>
</thead>
<tbody>
<tr><td class="column">In-Coming Material (RM/PM)</td><td><field name="incoming_doc_ref"/></td><td><field name="incoming_responsibility"/></td></tr>
<tr><td class="column">Return In-Coming Material (RM/PM)</td><td><field name="return_incoming_doc_ref"/></td><td><field name="return_incoming_resposibility"/></td></tr>

<!--
<tr><td class="column">Dispensed Material (RM/PM)</td><td><field name="dispensed_doc_ref"/></td><td><field name="dispensed_responsibility"/></td></tr>


<tr><td class="column">Approved Stored Material (RM/PM)</td><td><field name="approved_doc_ref"/></td><td><field name="approved_responsibility"/></td></tr>
<tr><td class="column">Customer Complaint</td><td><field name="customer_complaint_doc_ref"/></td><td><field name="customer_complaint_responsibility"/></td></tr>
-->
<tr><td class="column">Approved Finished Products</td><td><field name="fir_incoming_doc_ref"/></td><td><field name="approved_fg_responsibility"/></td></tr>
<tr><td class="column">Returned Finished Products</td><td><field name="return_fg_incoming_doc_ref"/></td><td><field name="returned_fg_responsibility"/></td></tr>
<tr><td class="column">Finished Products(Production Assy)</td><td><field name="fg_incoming_doc_ref"/></td><td><field name="finished_fg_assy_responsibility"/></td></tr>

</tbody>
</table>
       </page>
       <page string="Description of NC">
       <field name="description_of_nc"/>
       </page>
       <page string="Root Cause of NC" invisible="rca_required == 'no'">
       <field name="root_cause_of_nc"/>
       </page>
       <page string="Containment Action" invisible="rca_required == 'no'">
       <field name="containment_action_of_nc"/>
       </page>
       <page string="CAPA" invisible="rca_required == 'no'">
       <field name="capa_line_ids">
       <tree editable="bottom">
       <field name="issue"/>
       <field name="corrective_action"/>
       <field name="preventive_action"/>
       </tree>
       </field>
     
       </page>
       <page string="Comments on CAPA" invisible="rca_required == 'no'">
       <field name="comments_on_capa"/>
       </page>
       <page string="Status" invisible="sfg_option != True">
       <field name="defective_status_ids">
                    <tree editable="bottom">
                        <field name="defective_id"/>
                        <field name="aodr_no"/>
                        <field name="status"/>
                    </tree>
                </field>
       </page>
       <page string="Status" invisible="material_option != True">
       <field name="defective_status_ids">
                    <tree editable="bottom">
                        <field name="material_defective_id"/>
                        <field name="aodr_no"/>
                        <field name="status"/>
                    </tree>
                </field>
       </page>
       <page string="Status" invisible="fg_option != True">
       <field name="defective_status_ids">
                    <tree editable="bottom">
                        <field name="fg_defective_id"/>
                        <field name="aodr_no"/>
                        <field name="status"/>
                    </tree>
                </field>
       </page>
      
       
       </notebook> 
<templates>
<div class="container">
    <div class="row" style="margin-top:100px">
  <div class="col-6" style="padding: 0px;box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;">
     <table class="table_custom" >
     <tr><td colspan="2" class="table_custom_header" style="color:#fff">To Be Filled By <span style="font-size: 18px;padding: 0px; color: #ffcc00;">QC</span> Team</td></tr>
         <tr>
            <td style="padding: 8px;" class="column"><b>QC Comments</b></td>
            
            <td><field name="comments"/></td>
        </tr>
        
        <tr>
            <td style="padding: 8px;" class="column"><b>Action to be taken By</b></td>
            
            <td><field name="action_group"/><field name="rd_user" widget="many2many_tags" invisible="action_group != 'rd'"/></td>
        </tr>
        <tr>
            <td style="padding: 8px;" class="column"><b>Rework Decision</b></td>
            
            <td><field name="rework_action_by_qc"  widget="boolean_toggle"/>
            <field name="rework_responsible_rd_user" invisible="rework_action_by_qc != True"/>
            </td>
        </tr>
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>QC Tested By  </b></td>
            <td> 
                <button string="Approve" invisible="qa_sign" class="btn-primary custom_btn" type="object" name="action_qa_esign_btn"></button>
          <field name="qa_sign" widget="image"/></td>
        </tr>
        <tr invisible="qa_sign == False">
            <td style="padding: 8px;" class="column"><b>Tested On</b></td>
            <td><field name="qa_tested_on" readonly="1"/></td>
        </tr>
        <tr invisible="qa_sign == False">
            <td style="padding: 8px;" class="column"><b>Tested By</b></td>
            <td><field name="qa_by" readonly="1"/></td>
        </tr>
    </table></div>
  <div class="col-6" style="padding: 0px;box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;"><table class="table_custom" >
     <tr><td colspan="2" class="table_custom_header" style="color:#fff">To Be Filled By <span style="font-size: 18px;padding: 0px; color: #ffcc00;">SCG</span> Team</td></tr>
         <tr>
            <td style="padding: 8px;" class="column"><b>Comments</b></td>
            
            <td><field name="scg_comments"/></td>
        </tr>
        <tr>
            <td style="padding: 8px;" class="column"><b>Rework Action</b></td>
            
            <td><field name="rework_action"/></td>
        </tr>
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>Forwared By  </b></td>
            <td> 
                <button string="Approve" invisible="scg_approval_sign" class="btn-primary custom_btn" type="object" name="action_scg_esign_btn"></button>
          <field name="scg_approval_sign" widget="image"/></td>
        </tr>
        <tr invisible="scg_approval_sign == False">
            <td style="padding: 8px;" class="column"><b>Forwared On</b></td>
            <td><field name="scg_approval_on" readonly="1"/></td>
        </tr>
        <tr invisible="scg_approval_sign == False">
            <td style="padding: 8px;" class="column"><b>Forwared By</b></td>
            <td><field name="scg_approval_by" readonly="1"/></td>
        </tr>
    </table></div></div></div>
     <br></br><br></br>
     <div class="container">

    <div class="row">
      <div class="col-6" style="padding: 0px;box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;" invisible="rework_action == 'outsourcing_vendor'"><table class="table_custom" >
     <tr><td colspan="2" class="table_custom_header" style="color:#fff">To Be Filled By <span style="font-size: 18px;padding: 0px; color: #ffcc00;">Production</span> Team</td></tr>
         <tr>
            <td style="padding: 8px;" class="column"><b>Comments</b></td>
            
            <td><field name="production_comments"/></td>
        </tr>
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>Approved By  </b></td>
            <td> 
                <button string="Approve" invisible="production_approval_sign" class="btn-primary custom_btn" type="object" name="action_production_esign_btn"></button>
          <field name="production_approval_sign" widget="image"/></td>
        </tr>
        <tr invisible="production_approval_sign == False">
            <td style="padding: 8px;" class="column"><b>Approved On</b></td>
            <td><field name="production_approval_on" readonly="1"/></td>
        </tr>
        <tr invisible="production_approval_sign == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="production_approval_by" readonly="1"/></td>
        </tr>
    </table></div>
  <div class="col-6" style="padding: 0px;box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;">       <table class="table_custom" >

     <tr><td colspan="2" class="table_custom_header" style="color:#fff">To Be Filled By <span style="font-size: 18px;padding: 0px; color: #ffcc00;">QA</span> Team</td></tr>
         <tr>
            <td style="padding: 8px;" class="column"><b>Comments</b></td>
            
            <td><field name="qa_comments"/></td>
        </tr>
        <tr>
            <td style="padding: 8px;" class="column"><b>Action</b></td>
            
            <td><field name="qa_action"/></td>
        </tr>
         <!-- <tr>
            <td style="padding: 8px;" class="column"><b>Forward To</b></td>
            
            <td><field name="forward_to" widget="many2many_tags"/></td>
        </tr> -->
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>Approved By  </b></td>
            <td> 
                <button string="Approve" invisible="forward_sign" class="btn-primary custom_btn" type="object" name="action_forward_esign_btn"></button>
            <field name="forward_sign" widget="image"/></td>
        </tr>
        <tr invisible="forward_sign == False">
            <td style="padding: 8px;" class="column"><b>Approved On</b></td>
            <td><field name="forward_on" readonly="1"/></td>
        </tr>
        <tr invisible="forward_sign == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="forward_by" readonly="1"/></td>
        </tr>
        
    </table></div>
  </div></div>
   <br></br><br></br>
   <div class="container">

<div class="row">
   <div class="col-6" style="padding: 0px;box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;" invisible="action_group != 'rd'"><table class="table_custom" >
     <tr><td colspan="2" class="table_custom_header" style="color:#fff">To Be Filled By <span style="font-size: 18px;padding: 0px; color: #ffcc00;">R&amp;D</span> Team</td></tr>
         <tr>
            <td style="padding: 8px;" class="column"><b>Comments</b></td>
            
            <td><field name="rd_comments"/></td>
        </tr>
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>Approved By  </b></td>
            <td> 
                <button string="Approve" invisible="rd_approval_sign" class="btn-primary custom_btn" type="object" name="action_rd_esign_btn"></button>
          <field name="rd_approval_sign" widget="image"/></td>
        </tr>
        <tr invisible="rd_approval_sign == False">
            <td style="padding: 8px;" class="column"><b>Approved On</b></td>
            <td><field name="rd_approval_on" readonly="1"/></td>
        </tr>
        <tr invisible="rd_approval_sign == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="rd_approval_by" readonly="1"/></td>
        </tr>
    </table></div>
 <div class="col-6" style="padding: 0px;box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;background-color: #fff;border: solid 4px #9689c1;" invisible="rework_action_by_qc != True"><table class="table_custom" >
     <tr><td colspan="2" class="table_custom_header" style="color:#fff">To Be Filled By <span style="font-size: 18px;padding: 0px; color: #ffcc00;">R&amp;D</span> Team(Rework)</td></tr>
        <tr style="border-bottom: solid 1px #ccc;">
            <td style="padding: 8px;" class="column"><b>Approved By  </b></td>
            <td> 
                <button string="Approve" invisible="rework_rd_approval_sign" class="btn-primary custom_btn" type="object" name="action_rework_rd_esign_btn"></button>
          <field name="rework_rd_approval_sign" widget="image"/></td>
        </tr>
        <tr invisible="rework_rd_approval_sign == False">
            <td style="padding: 8px;" class="column"><b>Approved On</b></td>
            <td><field name="rework_rd_approval_on" readonly="1"/></td>
        </tr>
        <tr invisible="rework_rd_approval_sign == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="rework_rd_approval_by" readonly="1"/></td>
        </tr>
    </table></div>
   
     </div>
    
</div>
</templates>

                    </sheet>
                </form>
        </field>
    </record>
<menuitem id="ncmr_menu"
              name="Non-Conforming Material Report (NCMR)"
              parent="cnp_forms_menu_root" action="action_ncmr_form_list" groups="sos_inventory.sos_healthcare_user,sos_inventory.sos_scg_group_user,sos_inventory.sos_qa_user,sos_inventory.sos_rd_user,sos_inventory.sos_qc_user,sos_inventory.sos_management_user,sos_inventory.sos_production_user"/>
              
</odoo>
