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

    <record id="view_order_product_tree" model="ir.ui.view">
        <field name="name">sale.report.tree</field>
        <field name="model">sale.report</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Sales Analysis">
                <field name="date" invisible="1"/>
                <field name="user_id" invisible="1"/>
                <field name="year" invisible="1"/>
                <field name="day" invisible="1"/>
                <field name="month" invisible="1"/>
                <field name="shop_id" invisible="1"/>
                <field name="company_id" invisible="1" groups="base.group_multi_company"/>
                <field name="partner_id" invisible="1"/>
                <field name="product_id" invisible="1"/>
                <field name="categ_id" invisible="1"/>
                <field name="nbr" sum="# of Lines"/>
                <field name="product_uom_qty" sum="# of Qty"/>
                <field name="shipped_qty_1" sum="Shipped Qty"/>
                <field name="uom_name" invisible="not context.get('set_visible',False)"/>
                <field name="price_average" sum="Average Price"/>
                <field name="price_total" sum="Total Price"/>
                <field name="delay" sum="Commitment Delay"/>
                <field name="state" invisible="1"/>
                <field name="analytic_account_id" invisible="1" groups="base.group_extended"/>
            </tree>
        </field>
    </record>

    <record id="view_order_product_graph" model="ir.ui.view">
         <field name="name">sale.report.graph</field>
         <field name="model">sale.report</field>
         <field name="type">graph</field>
         <field name="arch" type="xml">
             <graph string="Sales Analysis" type="bar">
                 <field name="product_id"/>
                 <field name="price_total"/>
                 <field name="state" group="True"/>
             </graph>
         </field>
    </record>

    <record id="view_order_product_search" model="ir.ui.view">
        <field name="name">sale.report.search</field>
        <field name="model">sale.report</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
            <search string="Sales Analysis">
                <group>
                    <filter icon="terp-go-year" string="  Year  "
                        domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-01-01'))]"
                        help="Sales order created in current year"/>
                    <filter icon="terp-go-month" string="   Month   "
                        name="month"
                        domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-%%m-01'))]"
                        help="Sales order created in current month"/>
                    <filter icon="terp-go-month"
                         string="    Month-1    "
                         separator="1"
                         domain="[('date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
                         help="Sales order created in last month"/>
                    <separator orientation="vertical"/>
                    <filter icon="terp-document-new"
                        string="Quotations"
                        domain="[('state','=','draft')]"/>
                    <filter icon="terp-check"
                        string="Sales"
                        domain="[('state','not in',('draft','done','cancel'))]"/>
                    <separator orientation="vertical"/>
                    <filter icon="terp-sale"
                        string="Picked"
                        domain="[('shipped','=',True)]"/>
                    <separator orientation="vertical"/>
                    <field name="partner_id"/>
                    <field name="product_id"/>
                    <field name="user_id">
                        <filter icon="terp-personal"
                            string="My Sales"
                            help="My Sales"
                            domain="[('user_id','=',uid)]"/>
                    </field>
                </group>
                <newline/>
                <group expand="0" string="Extended Filters..." groups="base.group_extended">
                    <field name="date"/>
                    <field name="date_confirm"/>
                    <separator orientation="vertical"/>
                    <field name="shop_id" widget="selection"/>
                    <field name="categ_id" widget="selection"/>
                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                </group>
                <newline/>
                <group expand="1" string="Group By..." colspan="10" col="12">
                    <filter string="Salesman" icon="terp-personal" name="User" context="{'group_by':'user_id'}"/>
                    <filter string="Partner" icon="terp-personal" context="{'group_by':'partner_id'}"/>
                    <separator orientation="vertical"/>
                    <filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id','set_visible':True}"/>
                    <filter string="Default UoM" icon="terp-mrp" context="{'group_by':'uom_name'}"/>
                    <filter string="Category of Product" icon="terp-stock_symbol-selection" context="{'group_by':'categ_id'}"/>
                    <separator orientation="vertical"/>
                    <filter string="Analytic Account" icon="terp-folder-green" context="{'group_by':'analytic_account_id'}"/>
                    <separator orientation="vertical"/>
                    <filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
                    <separator orientation="vertical"/>
                    <filter string="Shop" icon="terp-go-home" context="{'group_by':'shop_id'}"/>
                    <filter string="Company" icon="terp-go-home" groups="base.group_multi_company" context="{'group_by':'company_id'}"/>
                    <separator orientation="vertical"/>
                   <filter string="Day" icon="terp-go-today" context="{'group_by':'day'}" help="Ordered date of the sales order"/>
                   <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" help="Ordered month of the sales order"/>
                   <filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" help="Ordered Year of the sales order"/>
                </group>
            </search>
        </field>
    </record>

    <record id="action_order_report_all" model="ir.actions.act_window">
        <field name="name">Sales Analysis</field>
        <field name="res_model">sale.report</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,graph</field>
        <field name="search_view_id" ref="view_order_product_search"/>
        <field name="view_id" ref="view_order_product_tree"/>
        <field name="context">{'search_default_month':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]}</field>
        <field name="help">With Sales Analysis consult your sales total amount suits to different group criteria (salesman, partner, product, etc.)</field>
    </record>

    <menuitem id="base.next_id_64" name="Reporting" parent="base.menu_base_partner" sequence="11"/>
    <menuitem action="action_order_report_all" id="menu_report_product_all" parent="base.next_id_64" sequence="1"/>

    <!--This views used in board_sale module -->
    <record id="view_sales_by_partner_tree" model="ir.ui.view">
        <field name="name">sales.by.partner.tree</field>
        <field name="model">sale.report</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Sales By Partner">
                <field name="partner_id"/>
                <field name="price_total"/>
            </tree>
        </field>
    </record>

    <record id="view_sales_by_partner_graph" model="ir.ui.view">
         <field name="name">sales.by.partner.graph</field>
         <field name="model">sale.report</field>
         <field name="type">graph</field>
         <field name="arch" type="xml">
             <graph string="Sales By Partner" type="bar">
                 <field name="partner_id" />
                 <field name="price_total" operator="+"/>
             </graph>
         </field>
    </record>

   <record id="action_sales_by_partner" model="ir.actions.act_window">
        <field name="name">Sales By Partner</field>
        <field name="res_model">sale.report</field>
        <field name="view_type">form</field>
        <field name="view_mode">graph,tree</field>
        <field name="domain">[('state','in',('manual','progress')),('date','&lt;=', time.strftime('%Y-%m-%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=90)).strftime('%Y-%m-%d'))]</field>
        <field name="view_id" ref="view_sales_by_partner_graph"/>
    </record>
    <record id="open_view_sales_by_partner_graph" model="ir.actions.act_window.view">
            <field eval="1" name="sequence"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="view_sales_by_partner_graph"/>
            <field name="act_window_id" ref="action_sales_by_partner"/>
   </record>
   <record id="open_view_sales_by_partner_tree" model="ir.actions.act_window.view">
            <field eval="2" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_sales_by_partner_tree"/>
            <field name="act_window_id" ref="action_sales_by_partner"/>
   </record>

    <record id="view_sales_by_salesman_tree" model="ir.ui.view">
        <field name="name">sales.by.salesman.tree</field>
        <field name="model">sale.report</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Sales By Salesman">
                <field name="user_id"/>
                <field name="price_total"/>
            </tree>
        </field>
    </record>

    <record id="view_sales_by_salesman_graph" model="ir.ui.view">
         <field name="name">sales.by.salesman.graph</field>
         <field name="model">sale.report</field>
         <field name="type">graph</field>
         <field name="arch" type="xml">
             <graph string="Sales By Salesman" type="bar">
                 <field name="user_id" />
                 <field name="price_total" operator="+"/>
             </graph>
         </field>
    </record>

   <record id="action_sales_by_salesman" model="ir.actions.act_window">
        <field name="name">Sales By Salesman</field>
        <field name="res_model">sale.report</field>
        <field name="view_type">form</field>
        <field name="view_mode">graph,tree</field>
        <field name="domain">[('state','in',('manual','progress','done')),('date','&lt;=', time.strftime('%Y-%m-%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=90)).strftime('%Y-%m-%d'))]</field>
        <field name="view_id" ref="view_sales_by_salesman_graph"/>
    </record>
   <record id="open_view_sales_by_salesman_graph" model="ir.actions.act_window.view">
            <field eval="7" name="sequence"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="view_sales_by_salesman_graph"/>
            <field name="act_window_id" ref="action_sales_by_salesman"/>
   </record>
    <record id="open_view_sales_by_salesman_tree" model="ir.actions.act_window.view">
            <field eval="9" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_sales_by_salesman_tree"/>
            <field name="act_window_id" ref="action_sales_by_salesman"/>
   </record>
    <record id="view_sales_product_total_price_tree" model="ir.ui.view">
        <field name="name">sold.product.total.price.tree</field>
        <field name="model">sale.report</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Sales by Products">
                <field name="product_id"/>
                <field name="price_total"/>
            </tree>
        </field>
    </record>

    <record id="view_sales_product_total_price_graph" model="ir.ui.view">
         <field name="name">sold.product.total.price.graph</field>
         <field name="model">sale.report</field>
         <field name="type">graph</field>
         <field name="arch" type="xml">
             <graph string="Sales by Products" type="bar">
                 <field name="product_id" />
                 <field name="price_total" operator="+"/>
             </graph>
         </field>
    </record>

   <record id="action_sales_product_total_price" model="ir.actions.act_window">
        <field name="name">Sales by Products</field>
        <field name="res_model">sale.report</field>
        <field name="view_type">form</field>
        <field name="view_mode">graph,tree</field>
        <field name="domain">[('state','in',('manual','progress','done')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=90)).strftime('%Y-%m-%d'))]</field>
        <field name="view_id" ref="view_sales_product_total_price_graph"/>
    </record>
    <record id="open_view_sales_product_total_price_graph" model="ir.actions.act_window.view">
            <field eval="3" name="sequence"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="view_sales_product_total_price_graph"/>
            <field name="act_window_id" ref="action_sales_product_total_price"/>
    </record>
    <record id="open_view_sales_product_total_price_tree" model="ir.actions.act_window.view">
            <field eval="4" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_sales_product_total_price_tree"/>
            <field name="act_window_id" ref="action_sales_product_total_price"/>
   </record>

    <record id="view_sales_by_month_tree" model="ir.ui.view">
        <field name="name">view.sales.by.month.tree</field>
        <field name="model">sale.report</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Sales By Month">
                <field name="month" />
                <field name="product_id" />
                <field name="price_total" />
            </tree>
        </field>
    </record>
    <record id="action_view_sales_by_month" model="ir.actions.act_window">
        <field name="name">Sales By Month</field>
        <field name="res_model">sale.report</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,graph</field>
        <field name="domain">[('state','in',('manual','progress','done')),('year','=', time.strftime('%Y'))]</field>
        <field name="context">{'group_by_no_leaf':1,'group_by':['month','product_id']}</field>
        <field name="view_id" ref="view_sales_by_month_tree"/>
    </record>

     <record id="view_top_quotations_tree" model="ir.ui.view">
            <field name="name">sale.top.quotations.tree</field>
            <field name="model">sale.order</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Top Quotations">
                    <field name="date_order"/>
                    <field name="name"/>
                    <field name="partner_id"/>
                    <field name="user_id" />
                    <field name="amount_untaxed" />
                    <field name="amount_total"/>
                </tree>
            </field>
        </record>

    <record id="action_quotation_for_sale" model="ir.actions.act_window">
        <field name="name">Top Quotations</field>
        <field name="res_model">sale.order</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('state','=','draft')]</field>
          <field name="view_id" ref="view_top_quotations_tree"/>
    </record>

</data>
</openerp>
