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

    <record id="sale_report_projected_margins_list" model="ir.ui.view">
        <field name="name">sale.report.view.list</field>
        <field name="model">sale.report</field>
        <field name="arch" type="xml">
            <list string="Sales Analysis" action="action_open_order" type="object">
                <field name="order_reference"/>
                <field name="product_id" string="Product" optional="show"/>
                <field name="price_subtotal" string="Sold" optional="show" sum="Total Sold"/>
                <field name="untaxed_delivered_amount" string="Delivered" optional="hide" sum="Total Delivered"/>
                <field name="untaxed_amount_invoiced" string="Invoiced" optional="show" sum="Total Invoiced"/>
                <field name="purchase_price" optional="show" sum="Total Cost"/>
                <field name="margin" sum="Total Margin"/>
                <field name="margin_percent" widget="percentage" optional="show"/>
            </list>
        </field>
    </record>

    <record id="sale_report_projected_margins_kanban" model="ir.ui.view">
        <field name="name">sale.report.view.kanban</field>
         <field name="model">sale.report</field>
        <field name="arch" type="xml">
            <kanban>
                 <templates>
                    <t t-name="card">
                        <div>
                           <field name="name" class="fw-bold"/>-<field name="partner_id"/><br/>
                           <field name="product_id"/><br/>
                           <field name="currency_id" invisible="1"/>
                           <field name="margin" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                        </div>
                    </t>
                </templates>
            </kanban>
        </field>
    </record>

    <record id="action_order_report_projected_margins" model="ir.actions.act_window">
        <field name="name">Projected Margins</field>
        <field name="res_model">sale.report</field>
        <field name="path">project-projected-margins</field>
        <field name="view_mode">list,kanban</field>
        <field name="view_id" ref="sale_report_projected_margins_list" />
        <field name="search_view_id" ref="sale.view_order_product_search" />
        <field name="context">{'search_default_Customer': 1, 'search_default_filter_order_date': 1}</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_empty_folder">No data to display</p>
            <p>This report performs analysis on projected margins of sales orders.</p>
        </field>
    </record>

</odoo>
