<?xml version="1.0" encoding="UTF-8"?>
<odoo>
 <record id="action_ir_form_list" model="ir.actions.act_window">
    <field name="name">Inward Register</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">sos_ir</field>
    <field name="view_mode">tree,form,kanban</field>
</record>
<record id="sos_ir_view_panel" model="ir.ui.view">
<field name="name">sos_ir.search</field>
<field name="model">sos_ir</field>
<field name="arch" type="xml">
<search position="inside">
<searchpanel>

<field name="received_goods_type" string="Type" icon="fa-list" enable_counters="1"/>

</searchpanel>
   <field name="supplier_name" string="Suppliers"/>
            <field name="service_provider_name" string="Service Providers"/>
            <field name="ir_no" string="IR No"/>
</search>

</field>
</record>
       <record id="ir_view_form" model="ir.ui.view">
      <field name="name">Form</field>
        <field name="model">sos_ir</field>
        <field name="arch" type="xml">
  <form string="Model Form">
    <header>
                    <button class="btn btn-primary" type="object"
                            name="action_report_ir_btn"><i class="fa fa-print"></i> Print</button>

                            
                </header>
                    <sheet>
 <h2 style="text-align: center;text-transform: uppercase;text-shadow: 1px 1p 1px #140718;color: #65407c;padding:5px;">Inward Register</h2><hr></hr><br></br>  
<div style="border: solid 1px #ccc;
    padding: 10px;
    margin-bottom: 20px;
    background-color: #f3f3f3;">
<group string="Rework (If any)">
<field name="orr_no"/>
<field name="iqi_no"/>
</group>
</div>
                        <group>
                            <!-- First Column -->
                            <group>
                            
                                <field name="ir_no"/>
                                <field name="received_goods_type"/>
                                <field name="wo_planned_at" invisible="received_goods_type != 'SFG'"/>
                                <field name="supplier_name" invisible="received_goods_type != 'Materials'"/>
                                <field name="service_provider_name" invisible="received_goods_type != 'SFG' or wo_planned_at != 'outsource'"/>
                                  <field name="supplier_address" invisible="received_goods_type != 'Materials'"/>
                            <field name="service_provider_address" invisible="received_goods_type != 'SFG' or wo_planned_at != 'outsource'"/>
                                <field name="po_no" invisible="received_goods_type != 'Materials'"/>
                                <field name="wo_no" invisible="received_goods_type != 'SFG' or wo_planned_at != 'outsource'"/>
                                <field name="wo_no_inhouse" invisible="wo_planned_at != 'inhouse'"/>
                                <field name="parcel_count"/>
                                <field name="vehicle_type"/>
                                <field name="boxes_sealing"/>

                            </group>
                            <!-- Second Column -->
                            <group>
                          
                                <!-- <field name="dc_no" invisible = "received_goods_type == 'Materials'"/> -->
                              <field name="indent_no"/>
                                <field name="receiving_dept"/>
                                <field name="received_date"/>
                                <field name="receiving_by"/>
                                  <field name="dc_no_char"/>
                                <field name="dc_date"/>
                                
                                <field name="test_report" widget="binary" filename="test_report_filename"/>
                                <field name="test_report_filename" invisible="1"/>
                                <button name="action_view_invoice" invisible="not test_report" string="View Invoice" type="object" class="btn-primary" icon="fa-eye"/>
                            

                            </group>
                          
                        </group>
                        
                
                             <notebook>
                            <page string="Components" invisible="received_goods_type != 'Materials'">
                                <field name="line_ids_material"  widget="one2many">
                                    <tree editable="bottom">
                                    <field name="batch_no"/>
                                        <field name="component_id"/>
                                        <field name="material_code"/>
                                        <field name="name" readonly="False"/>
                                        <field name="uom"/>
                                        <field name="inspection_method" widget="color_picker"/>
                                        <field name="invoice_qty"/>
                                        <field name="order_qty"/>
                                        <field name="qty"/>
                                        <field name="unit_price"/>
                                        <field name="test_report" widget="binary" filename="test_report_filename"/>
                <field name="test_report_filename" column_invisible="1"/>
                                <button name="action_view_pdf" invisible="not test_report" type="object" string="View" class="btn-primary" icon="fa-eye"/>

                <!-- <button class="btn btn-primary" type="object"
                            name="action_view_pdf"><i class="fa fa-eye"></i> View</button> -->
<field name="write_uid" string="Last Edited By" optional="hide"/>
                <field name="write_date" string="Last Edited On" optional="hide"/>
                                    </tree>
                                 
                                </field>
   
                            </page>
                            <page string="Semi Finished Goods" invisible="received_goods_type != 'SFG'">
                                <field name="line_ids_sfg"  widget="one2many">
                                    <tree editable="bottom">
                                    <field name="batch_no"/>
                                        <field name="component_id"/>
                                         <field name="sfg_code" string="SFG Name"/>
                                         <field name="invoice_qty"/>
                                         <field name="order_qty"/>
                                        <field name="qty"/>
                                    <field name="test_report"  widget="binary"  filename="test_report_filename"/>
                <field name="test_report_filename" column_invisible="1"/>
                                                <button name="action_view_pdf" invisible="not test_report" type="object" string="View" class="btn-primary" icon="fa-eye"/>

                                    </tree>
                                 
                                </field>
   
                            </page>
                            <page string="Products" invisible="received_goods_type != 'FG'">
                                <field name="line_ids_fg"  widget="one2many">
                                    <tree editable="bottom">
                                    <field name="batch_no"/>
                                        <field name="component_id"/>
                                        <field name="fg_code"/>
                                        <field name="invoice_qty"/>
                                        <field name="order_qty"/>
                                        <field name="qty"/>
                                    <field name="test_report"  widget="binary"  filename="test_report_filename"/>
                <field name="test_report_filename" column_invisible="1"/>
                                                <button name="action_view_pdf" invisible="not test_report" type="object" string="View" class="btn-primary" icon="fa-eye"/>

                                    </tree>
                                 
                                </field>
   
                            </page>
                            <page string="Miscellaneous">
                            <group>
                            <field name="service_charge"/>
                            </group>
                            </page>
                            <br></br><br></br>
                          
                          
                        </notebook>
                        <templates>

<div class="row">
<div class="col-4">
    <!-- First Table -->
   <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 Incharge</b>
            <br></br><br></br>
                <button string="Approve" invisible="stores_approval_image" class="btn-primary custom_btn" type="object" name="action_report_esign_btn"></button>
            </td>
            <td><field name="stores_approval_image" widget="image"/></td>
        </tr>
        <tr invisible="stores_approval_image == False">
            <td style="padding: 8px;" class="column"><b>Approved On</b></td>
            <td><field name="stores_approved_on" readonly="1"/></td>
        </tr>
        <tr invisible="stores_approval_image == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="stores_approval_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>Department In-Charge</b>
            <br></br><br></br>
                <button string="Approve" invisible="dept_in_charge_image" class="btn-primary custom_btn" type="object" name="action_deptincharge_esign_btn"></button>
            </td>
            <td><field name="dept_in_charge_image" widget="image"/></td>
        </tr>
        <tr invisible="dept_in_charge_image == False">
            <td style="padding: 8px;" class="column"><b>Approved On</b></td>
            <td><field name="dept_in_charge_approved_on" readonly="1"/></td>
        </tr>
        <tr invisible="dept_in_charge_image == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="dept_in_charge_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>Top Management</b>
            <br></br><br></br>
                <button string="Approve" invisible="top_management_approval_image" class="btn-primary custom_btn" type="object" name="action_topmanagement_esign_btn"></button>
            </td>
            <td><field name="top_management_approval_image" widget="image"/></td>
        </tr>
        <tr invisible="top_management_approval_image == False">
            <td style="padding: 8px;" class="column"><b>Approved On</b></td>
            <td><field name="top_management_approved_on" readonly="1"/></td>
        </tr>
        <tr invisible="top_management_approval_image == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="top_management_name" readonly="1"/></td>
        </tr>
    </table>
</div>
</div>
</templates>

        <!-- <div style="width: 100%; text-align: right;margin-top:100px">
    <table style="color: #000;background-color: #fff;width: 50%; display: inline-table; border: solid 1px #ccc;">
    <tr>
    <td style="padding: 8px;" class="column"><b>Stores-RM/PM In charge Sign</b></td>
    <td> <button  string="Approve"  invisible="stores_approval_image" class="btn-primary custom_btn" type="object" name="action_report_esign_btn"></button>
    </td>
    <td><field name="stores_approval_image" widget="image"/></td>
    </tr>
    </table>
    </div> -->
                    </sheet>
                </form>
        </field>
    </record>





    <record id="ir_view_tree" model="ir.ui.view">
        <field name="name">ir.view.tree</field>
        <field name="model">sos_ir</field>
        <field name="arch" type="xml">
            <tree>
                <!-- Fields to display in IMIR tree view -->
                <field name="ir_no"/>
                <field name="received_date" string="Received On"/>
                  <field name="dc_no_char"/>
                <field name="dc_date" string="Bill Date"/>
                      <field name="stores_approval_name" string="Stores Received By" widget="many2one_avatar_user"/>
              <field name="dept_in_charge_name" string="Dept In-Charge" widget="many2one_avatar_user"/>

            <field name="top_management_name" string="Top Management Approved By" widget="many2one_avatar_user"/>
           
                <!-- <field name="supplier_name" invisible="received_goods_type != 'Materials'"/>
                <field name="service_provider_name" invisible="received_goods_type != 'SFG'"/>
                <field name="po_no" invisible="received_goods_type != 'Materials'"/>
                <field name="wo_no" invisible="received_goods_type != 'SFG'"/> -->
<!-- More fields as per your requirements -->
            </tree>
        </field>
    </record>
    <!-- Action for IR -->
    <record id="action_ir_form" model="ir.actions.act_window">
        <field name="name">Inward Register</field>
        <field name="res_model">sos_ir</field>
        <field name="view_mode">form</field>
        <field name="view_ids" eval="[(5, 0, 0),
                                  (0, 0, {'view_mode': 'tree', 'view_id': ref('ir_view_tree')}),
                                  (0, 0, {'view_mode': 'form', 'view_id': ref('ir_view_form')})]"/>

    </record>



    <!-- Menu Items -->
    <menuitem id="menu_my_model_form_1" name="Inward Register (IR)"
              parent="scg_forms_menu_root" action="action_ir_form" groups="sos_inventory.sos_scg_group_manager,sos_inventory.sos_scg_group_user,sos_inventory.sos_logistics_user,sos_inventory.sos_management_user,sos_inventory.sos_finance_user"/>


</odoo>
