<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <!-- Tree View -->
    <record id="view_prev_action_plan_tree" model="ir.ui.view">
    <field name="name">sos_sales_action_plan.tree.prev</field>
    <field name="model">sos_sales_action_plan</field>
    <field name="arch" type="xml">
        <tree string="Previous Action Plans">
            <field name="customer_name"/>
            <field name="date"/>
            <field name="action_plan"/>
        </tree>
    </field>
</record>

    <record id="view_sos_sales_action_plan_tree" model="ir.ui.view">
        <field name="name">sos_sales_action_plan.tree</field>
        <field name="model">sos_sales_action_plan</field>
        <field name="arch" type="xml">
            <tree>
          
                  <field name="customer_name"/>
                  <field name="sales_executive"/>
                  <field name="date"/>
                  <field name="action"/>
                  <field name="status" widget="badge" decoration-danger="status == 'close'" decoration-success="status == 'open'"/>  
            </tree>
        </field>
    </record>
<record id="sos_sales_action_plan_view_panel" model="ir.ui.view">
    <field name="name">sos_sales_action_plan.search</field>
    <field name="model">sos_sales_action_plan</field>
    <field name="arch" type="xml">
        <search>
            <searchpanel>
                <field name="product" string="Products" icon="fa-list-ul" enable_counters="1"/>
                <field name="current_spenco_status" string="Current SPENCO Status" icon="fa-list-ul" enable_counters="1"/>

            </searchpanel>

            <!-- Add fields to search on -->
            <field name="sales_executive" string="Sales Person"/>
            <field name="customer_name" string="Customer Name"/>
      
        </search>
    </field>
</record>
    <!-- Form View -->
    <record id="view_sos_sales_action_plan_form" model="ir.ui.view">
        <field name="name">sos_sales_action_plan.form</field>
        <field name="model">sos_sales_action_plan</field>
        <field name="arch" type="xml">
            <form>
            <header>
            <button invisible="state == 'draft' or update_done" class="btn btn-primary" type="object" name="update_casediary"><i class="fa fa-copy"></i> Update Case Diary</button>
            <button invisible="state == 'draft'" class="btn btn-primary" type="object" name="view_casediary"><i class="fa fa-copy"></i> View Case Diary</button>

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

    <group>
    <group>
    <field name="update_done" invisible="1"/>
    <field name="status"/>
    <field name="sales_executive" readonly="state == 'confirmed'"/>
    <field name="date" readonly="state == 'confirmed'"/>
    <field name="action_type" readonly="state == 'confirmed'"/>
    <field name="customer_name" readonly="state == 'confirmed'"/>
    <field name="quote_no_selector" readonly="state == 'confirmed'" options="{'no_create': True}"/>
    <field name="quote_no" readonly="state == 'confirmed'" placeholder="Or type new Quote/W.O No"/>   
    <field name="end_customer_name" readonly="state == 'confirmed'" placeholder="Or type new End Customer Name"/>
    </group>
    <group>
     <field name="product" readonly="state == 'confirmed'"/>
     <field name="ce_product_type" groups="sos_inventory.sos_ce_user,sos_inventory.sos_ce_head,sos_inventory.sos_finance_user,sos_inventory.sos_management_user"/>

    <field name="location" readonly="state == 'confirmed'"/>
    <field name="quantity" readonly="state == 'confirmed'"/>
    <field name="sales_head" readonly="state == 'confirmed'"/>
    <field name="action" readonly="state == 'confirmed'"/>
<label for="action_plan" string="Action Plan"/>
<div class="d-flex align-items-center" style="gap: 10px; margin-top:5px;">
    <field name="action_plan" readonly="state == 'confirmed'" class="flex-grow-1"/>

    <!-- The button stays to the right -->
    <!-- <button name="action_prev_action_plans"
            string="Previous action plans"
            class="btn btn-primary"
            type="object"
            invisible="customer_name == False"/> -->
</div>    </group>
    </group>

    <br></br>

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

        <br></br>

      <group>
    <group>
    <field name="state" invisible="1"/>
    <field name="value"/>
     <field name="current_spenco_status" required="state == 'confirmed'"/>
     <field name="po_no" invisible="current_spenco_status != 'Commercial Order'"/>
     <field name="po_copy" invisible="current_spenco_status != 'Commercial Order'" widget="binary" filename="po_copy_filename"/>
      <field name="po_copy_filename" invisible="1"/>
     <button name="action_view_po" invisible="not po_copy" string="View PO" type="object" class="btn-primary" icon="fa-eye"/>


    </group>
    <group>
    <field name="result"/>
    <field name="next_action_date" required="state == 'confirmed'"/>
    
    </group>
    </group>
      
                </sheet>
            </form>
        </field>
    </record>

    <!-- Action -->
    <record id="action_sos_sales_action_plan" model="ir.actions.act_window">
        <field name="name">Sales Action Plan</field>
        <field name="res_model">sos_sales_action_plan</field>
        <field name="view_mode">tree,form</field>
    </record>

    <!-- Menu -->
    <menuitem id="menu_sos_sales_action_plan" name="ACTION PLAN" sequence="6" parent="sos_sales_menu_root" action="action_sos_sales_action_plan" groups="sos_inventory.sos_finance_user,sos_inventory.sos_sales_user,sos_inventory.sos_management_user,sos_inventory.sos_ce_head,sos_inventory.sos_ce_user"/>
</odoo>
