<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- Form View for sos_sales_achievement_report -->
<record id="view_sos_sales_achievement_report_form" model="ir.ui.view">
<field name="name">sos.sales.achievement.report.form</field>
<field name="model">sos_sales_achievement_report</field>
<field name="arch" type="xml">
<form string="Sales Achievement Report">
<header>
<button class="btn btn-primary" type="object"
name="action_report_achievement_btn"><i class="fa fa-print"></i> Print Report</button>
</header>
<sheet>
<h2 style="text-align: center;text-transform: uppercase;text-shadow: 1px 1p 1px #140718;color: #65407c;padding:5px;">Sales Achievements Report</h2><hr></hr><br></br>  
<group>
<group><field name="financial_year" style="font-size: 20px; pointer-events: none; color: #793595;"/>
</group>
<group><field name="category" /></group>
<group><field name="overall_target" /></group>
<group><field name="sales_person" invisible="category == 'export'"/></group>
<table groups="sos_inventory.sos_finance_user,sos_inventory.sos_management_user" style="margin-left: 15px;"><tr>
<td><group><field name="opening_balance"/>
</group></td>
<td><button name="action_view_brief_lines_acc"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 0}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
</td>
</tr>
</table>
 </group>
<button groups="sos_inventory.sos_finance_user,sos_inventory.sos_management_user" name="action_yet_to_bill"
            type="object"
            string="📝 Yet To Bill"
            class="btn-primary"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
<br></br><br></br>
<table class="table_custom">
    <thead>
        <tr style="background-color: lavender;">
            <th class="column">Month</th>
            <th class="column">April</th>
            <th class="column">May</th>
            <th class="column">June</th>
            <th class="column">July</th>
            <th class="column">August</th>
            <th class="column">September</th>
            <th class="column">October</th>
            <th class="column">November</th>
            <th class="column">December</th>
            <th class="column">January</th>
            <th class="column">February</th>
            <th class="column">March</th>
            <th class="column">Total</th>
            <th class="column">YTD</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td class="column" style="background-color: lavender;">Target</td>
            <td><field name="planned_target_april" /></td>
            <td><field name="planned_target_may" /></td>
            <td><field name="planned_target_june" /></td>
            <td><field name="planned_target_july" /></td>
            <td><field name="planned_target_august" /></td>
            <td><field name="planned_target_september" /></td>
            <td><field name="planned_target_october" /></td>
            <td><field name="planned_target_november" /></td>
            <td><field name="planned_target_december" /></td>
            <td><field name="planned_target_january" /></td>
            <td><field name="planned_target_february" /></td>
            <td><field name="planned_target_march" /></td>
            <td><field name="planned_target_total" /></td>
            <td><field name="ytd_target" /></td>
        </tr>
        <tr>
            <td class="column" style="background-color: lavender;">PO Received</td>
           <td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_april" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 4}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>
 <td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_may" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 5}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>
 <td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_june" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 6}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>
 <td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_july" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 7}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>
 <td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_august" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 8}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>
   <td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_september" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 9}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>
   <td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_october" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 10}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>
      <td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_november" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 11}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>              
<td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_december" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 12}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>  

<td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_january" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 1}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>  

<td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_february" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 2}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>

<td>
  <div style="display: flex; align-items: center;">
    <field name="actual_target_march" readonly="1" widget="monetary"/>
    <button name="action_view_brief_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 3}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
  </div>
</td>
        
            <td><field name="actual_target_total" /></td>
            <td><field name="ytd_sales" /></td>
        </tr>
        <tr>
            <td class="column" style="background-color: lavender;">%</td>
            <td><field name="achievement_percentage_april" /></td>
            <td><field name="achievement_percentage_may" /></td>
            <td><field name="achievement_percentage_june" /></td>
            <td><field name="achievement_percentage_july" /></td>
            <td><field name="achievement_percentage_august" /></td>
            <td><field name="achievement_percentage_september" /></td>
            <td><field name="achievement_percentage_october" /></td>
            <td><field name="achievement_percentage_november" /></td>
            <td><field name="achievement_percentage_december" /></td>
            <td><field name="achievement_percentage_january" /></td>
            <td><field name="achievement_percentage_february" /></td>
            <td><field name="achievement_percentage_march" /></td>
            <td><field name="achievement_percentage_total" /></td>
            <td><field name="ytd_sales_percentage" /></td>
        </tr>
        <tr groups="sos_inventory.sos_finance_user,sos_inventory.sos_management_user" style="background-color: lavender;"><td class="column" colspan="15" style="text-align: center;
    color: #000;text-transform: capitalize;">To be filled by Accounts team</td></tr>
        <tr groups="sos_inventory.sos_finance_user,sos_inventory.sos_management_user">
        <field name="can_edit_billed_target" invisible="1"/>
            <td class="column" style="background-color: lavender;">Billed</td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="billed_target_april" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 4, 'action': 'Billed'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="billed_target_may" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 5, 'action': 'Billed'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="billed_target_june" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 6, 'action': 'Billed'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="billed_target_july" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 7, 'action': 'Billed'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="billed_target_august" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 8, 'action': 'Billed'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="billed_target_september" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 9, 'action': 'Billed'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="billed_target_october" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 10, 'action': 'Billed'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="billed_target_november" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 11, 'action': 'Billed'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="billed_target_december" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 12, 'action': 'Billed'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="billed_target_january" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 1, 'action': 'Billed'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="billed_target_february" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 2, 'action': 'Billed'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="billed_target_march" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 3, 'action': 'Billed'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
            <td><field readonly="not can_edit_billed_target" name="billed_target_total" /></td>
            <td><field readonly="not can_edit_billed_target" name="ytd_billed" /></td>
        </tr>
 
        <tr groups="sos_inventory.sos_finance_user,sos_inventory.sos_management_user">
            <td class="column" style="background-color: lavender;">Collected</td>
          <td>
      <div style="display: flex; align-items: center;">
      <field name="collected_target_april" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 4, 'action': 'Collected'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="collected_target_may" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 5, 'action': 'Collected'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="collected_target_june" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 6, 'action': 'Collected'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="collected_target_july" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 7, 'action': 'Collected'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="collected_target_august" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 8, 'action': 'Collected'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="collected_target_september" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 9, 'action': 'Collected'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="collected_target_october" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 10, 'action': 'Collected'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="collected_target_november" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 11, 'action': 'Collected'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="collected_target_december" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 12, 'action': 'Collected'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="collected_target_january" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 1, 'action': 'Collected'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
      <td>
      <div style="display: flex; align-items: center;">
      <field name="collected_target_february" readonly="1" widget="monetary"/>
      <button name="action_view_billed_lines"
      type="object"
      string="📊"
      class="btn-link"
      context="{'month': 2, 'action': 'Collected'}"
      style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
      </div>
      </td>
            <td>
            <div style="display: flex; align-items: center;">
            <field name="collected_target_march" readonly="1" widget="monetary"/>
            <button name="action_view_billed_lines"
            type="object"
            string="📊"
            class="btn-link"
            context="{'month': 3, 'action': 'Collected'}"
            style="padding: 0; border: none; background: none; font-size: 18px; box-shadow: 4px 5px 5px #e3e2e2;"/>
            </div>
            </td>
            <td><field readonly="not can_edit_billed_target" name="collected_target_total" /></td>
            <td><field readonly="not can_edit_billed_target" name="ytd_collected" /></td>
        </tr>
               <tr groups="sos_inventory.sos_finance_user,sos_inventory.sos_management_user">
        <field name="can_edit_billed_target" invisible="1"/>
            <td class="column" style="background-color: lavender;">Yet to Bill</td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_april" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_may" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_june" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_july" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_august" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_september" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_october" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_november" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_december" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_january" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_february" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_march" /></td>
            <td><field readonly="not can_edit_billed_target" name="yet_to_billed_target_total" /></td>
            <td><field readonly="not can_edit_billed_target" name="ytd_yet_to_billed" /></td>
        </tr>
    </tbody>
</table>


                </sheet>
            </form>
        </field>
    </record>

    <!-- Tree View for sos_sales_achievement_report -->
    <record id="view_sos_sales_achievement_report_tree" model="ir.ui.view">
        <field name="name">sos.sales.achievement.report.tree</field>
        <field name="model">sos_sales_achievement_report</field>
        <field name="arch" type="xml">
            <tree string="Sales Achievement Reports">
                <field name="financial_year" />
                <field name="category"/>
                <field name="sales_person" />
                <field name="overall_target" />
            </tree>
        </field>
    </record>

    <!-- Action to Open sos_sales_achievement_report -->
    <record id="action_sos_sales_achievement_report" model="ir.actions.act_window">
        <field name="name">Sales Achievement Report</field>
        <field name="res_model">sos_sales_achievement_report</field>
        <field name="view_mode">tree,form</field>
         <field name="context">{'group_by': 'financial_year'}</field>
        <field name="help" type="html">
            <p>Create and manage sales achievement reports.</p>
        </field>
    </record>
<menuitem id="sos_sales_achievement_report" name="Sales Achievements Report"
          parent="sos_sales_report" sequence="3"
          action="action_sos_sales_achievement_report"/>

</odoo>
