<?xml version="1.0" encoding="UTF-8"?>
<odoo>
 <record id="action_wo_form_list" model="ir.actions.act_window">
    <field name="name">Work Order</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">sos_wo</field>
    <field name="view_mode">tree,form,kanban</field>
</record>
<record id="action_amend_server_action" model="ir.actions.server">
    <field name="name">📝 Amend</field>
    <field name="model_id" ref="model_sos_wo"/>
    <field name="binding_model_id" ref="model_sos_wo"/>
    <field name="state">code</field>
    <field name="code">
        action = model.action_amend()
    </field>
</record>
<record id="sos_wo_view_panel" model="ir.ui.view">
<field name="name">sos_wo.search</field>
<field name="model">sos_wo</field>
<field name="arch" type="xml">
<search position="inside">
<searchpanel>

<field name="wo_planned_at" string="WO Planned At" icon="fa-list-ul" enable_counters="1"/>
<field name="supplier_name" string="Service Providers" icon="fa-list" enable_counters="1"/>


</searchpanel>
 <field name="wo_no" string="Work Order No"/>

<filter string="Open" name="active" domain="[('wo_status', '=','open')]"/>
<filter string="Closed" name="noactive" domain="[('wo_status', '=','close')]"/>
</search>

</field>
</record>
    <record id="sos_wo_view_tree" model="ir.ui.view">
        <field name="name">sos_wo.view.tree</field>
        <field name="model">sos_wo</field>
        <field name="arch" type="xml">
            <tree>
                
                <field name="wo_no"/>
                 <field name="wo_date"/>
                     <field name="stores_manager_approved_by" string="Dept Incharge Approved By" widget="many2one_avatar_user"/>
            <field name="top_management_approved_by" string="Top Management Approved By" widget="many2one_avatar_user"/>
           
                 <field name="rounded_total_value" string="WO Value"/>

                 <field name="wo_status" widget="badge" decoration-warning="wo_status == 'amend'" decoration-success="wo_status == 'close'" decoration-danger="wo_status == 'open'"/>
                 <field name="progress" widget="progressbar"/>
<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_wo_form_view" model="ir.ui.view">
      <field name="name">Form</field>
        <field name="model">sos_wo</field>
        <field name="arch" type="xml">
  <form string="Model Form">
                              <header>
                    <button class="btn btn-primary" type="object"
                            name="action_report_wo_btn"><i class="fa fa-print"></i> Print</button>
                    
                            
                </header>
                    <sheet>

      <widget name="web_ribbon" text="Open" bg_color="bg-danger" invisible="wo_status == 'close' or wo_status == 'amend'"/>
      <widget name="web_ribbon" text="Closed" bg_color="bg-success" invisible="wo_status == 'open'"/>
      <widget name="web_ribbon" text="Amended" bg_color="bg-warning" invisible="wo_status != 'amend'"/>

 <h2 style="text-align: center;text-transform: uppercase;text-shadow: 1px 1p 1px #140718;color: #65407c;padding:5px;">Work Order</h2><hr></hr><br></br>  

                        <!-- Topmost Group -->
                        <group>
                            <!-- First Column -->
                            <group>
                                 <field name="wo_status" invisible="1"/>
                                <field name="wo_no"/>
                                <field name="wo_date"/>
                                <field name="plan_ref_no"/>
                                <field name="wo_planned_at"/>
                                <field name="supplier_name" invisible="wo_planned_at == 'inhouse'"/>
                                <field name="supplier_address" invisible="wo_planned_at == 'inhouse'"/>
                                <field name="quotation_no" invisible="wo_planned_at == 'inhouse'"/>
                                <field name="quotation_date" invisible="wo_planned_at == 'inhouse'"/>
                                <field name="sarf_no" invisible="wo_planned_at == 'inhouse'"/>
                                
                            </group>
                            <!-- Second Column -->
                            <group invisible="wo_planned_at == 'inhouse'">
                             <field name="Contact_details"/>
                                <field name="material_delivery_required_date"/>
                                <field name="supplier_gst_no"/>
                                <field name="sosaley_gst_no"/>
                                <field name="invoicing_address"/>
                                <field name="delivery_address"/>
                                  <field name="dc_no"/>
                            </group>
                        </group>
                        
                
                             <notebook>
                            <page string="Components">
  <div style="display: flex;
    align-items: center;
    float: right;
    margin-bottom: 20px;
    border: solid 1px #ccc;
    padding: 5px;
    font-size: 13px;">
    <div style="width: 10px; height: 10px; background-color: #008818; margin-right: 10px;"></div>
    <span>Received</span>
    
    <div style="width: 10px; height: 10px; background-color: #9d6801; margin-right: 10px; margin-left: 20px;"></div>
    <span>Partially Received</span>
    
    <div style="width: 10px; height: 10px; background-color: #212529; margin-right: 10px; margin-left: 20px;"></div>
    <span>Not Received</span>
</div>
                                <field name="line_ids" readonly="top_management_approved_by" invisible="wo_planned_at != 'inhouse'">
                                    <tree footer="false" editable="bottom" decoration-success="status == 2" decoration-warning="status == 1">
                                    <field name="status" column_invisible="1"/>
                                    <field name="wo_planned_at" column_invisible="1" />
                                    <field name="component_id"/>
                                    <field name="qp"/>
                                    <field name="hsn_code"/>
                                        <field name="quantity"/>
                                    </tree>
                                 
                                </field>
                                <field name="line_ids" readonly="top_management_approved_by" invisible="wo_planned_at == 'inhouse'">
                                    <tree footer="false" editable="bottom" decoration-success="status == 2" decoration-warning="status == 1">
                                    <field name="status" column_invisible="1"/>
                                    <field name="wo_planned_at" column_invisible="1" />
                                    <field name="component_id"/>
                                    <field name="qp"/>
                                    <field name="hsn_code"/>
                                        <field name="unit_price" />
                                        <field name="quantity"/>
                                        <field name="tax" />
                                        <field name="total_price" />
                                    </tree>
                                 
                                </field>
<div invisible="wo_planned_at == 'inhouse'" class="oe_subtotal_footer" style="float: right;
    padding: 34px;
    border: solid 1px #ccc;
    font-weight: bold;
    box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;">

    <!-- Gross Value Field -->
    <div style="margin-bottom: 10px;">
        <label for="gross_value" style="font-weight: bold; margin-right: 10px;">Gross Value</label>
        <field name="gross_value" widget="monetary" options="{'currency_field': 'currency_id'}" class="oe_inline"/>
    </div>


    <!-- Total Value Field -->
    <!-- <div>
        <label for="total_value" style="font-weight: bold; margin-right: 10px;">Total Value</label>
        <field name="total_value" widget="monetary" options="{'currency_field': 'currency_id'}" class="oe_inline"/>
    </div> -->

      <div style="margin-bottom: 10px;">
        <label for="adjustment_value" style="font-weight: bold; margin-right: 10px;">Adjustment</label>
        <field name="adjustment_value" widget="monetary" options="{'currency_field': 'currency_id'}" class="oe_inline"/>
    </div>

       <div style="font-size:20px">
        <label for="rounded_total_value" style="font-weight: bold; margin-right: 10px;">Final Value</label>
        <field name="rounded_total_value" widget="monetary" options="{'currency_field': 'currency_id'}" class="oe_inline"/>
    </div>


</div>
                            </page>
                            <page string="Terms and Conditions" invisible="wo_planned_at == 'inhouse'">
                            <field name="terms_conditions"/>
                            </page>
                        </notebook>
                                    <br></br><br></br>

<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>
            <td style="padding: 8px;" class="column"><b>Remarks</b></td>
            <td><field name="remarks"/></td>
        </tr>
        <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_approved_image" class="btn-primary custom_btn" type="object" name="action_esign_btn"></button>
            </td>
            <td><field name="stores_approved_image" widget="image"/></td>
        </tr>
        <tr invisible="stores_approved_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_approved_image == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="stores_approved_by" readonly="1"/></td>
        </tr>
    </table>
</div>
<div class="col-4">
    <!-- Second 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>Department Incharge</b>
                        <br></br><br></br>

                <button string="Approve" invisible="stores_manager_approved_image" class="btn-primary custom_btn" type="object" name="action_head_esign_btn"></button>
            </td>
            <td><field name="stores_manager_approved_image" widget="image"/></td>
        </tr>
        <tr invisible="stores_manager_approved_image == False">
            <td style="padding: 8px;" class="column"><b>Approved On</b></td>
            <td><field name="stores_manager_approved_on" readonly="1"/></td>
        </tr>
        <tr invisible="stores_manager_approved_image == False">
            <td style="padding: 8px;" class="column"><b>Approved By</b></td>
            <td><field name="stores_manager_approved_by" readonly="1"/></td>
        </tr>
    </table>
</div>
<div class="col-4">
    <!-- Third 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>Top Management</b>
                        <br></br><br></br>

                <button string="Approve" invisible="top_management_approval_image" class="btn-primary custom_btn" type="object" name="action_top_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_approved_by" readonly="1"/></td>
        </tr>
    </table>
    </div>
</div>
                    </sheet>
                </form>
        </field>
    </record>
<menuitem id="wo_menu"
              name="Work Order (WO)"
              parent="scg_forms_menu_root" action="action_wo_form_list" groups="sos_inventory.sos_scg_group_manager,sos_inventory.sos_scg_group_user,sos_inventory.sos_finance_user,sos_inventory.sos_management_user,sos_inventory.sos_logistics_user"/>
              

</odoo>
