<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
 <!-- Report for project issue -->
        <record id="view_project_issue_report_tree" model="ir.ui.view">
            <field name="name">project.issue.report.tree</field>
            <field name="model">project.issue.report</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Issues Analysis">
                    <field name="name" invisible="1"/>
                    <field name="month" invisible="1"/>
                    <field name="project_id" invisible="1"/>
                    <field name="type_id" invisible="1"/>
                    <field name="version_id" string="Version" invisible="1"/>
                    <field name="priority" invisible="1"/>
                    <field name="company_id" invisible="1" groups="base.group_multi_company"/>
                    <field name="section_id" invisible="1"/>
                    <field name="user_id" invisible="1"/>
                    <field name="categ_id" invisible="1"/>
                    <field name="channel_id" invisible="1"/>
                    <field name="partner_id" invisible="1"/>
                    <field name="task_id" invisible="1"/>
                    <field name="assigned_to" invisible="1"/>
                    <field name="date_closed" invisible="1"/>
                    <field name="state" invisible="1"/>
                    <field name="day" invisible="1"/>
                    <field name="nbr" string="#Project Issues" sum='#Number of Project Issues'/>
                    <field name="delay_open" avg='Avg Opening Delay'/>
                    <field name="delay_close" avg='Avg Closing Delay'/>
                    <field name="working_hours_open" avg='Open Working Hours'/>
                    <field name="working_hours_close" avg='Close Working hours'/>
                    <field name="email" sum='# Emails'/>
                  </tree>
            </field>
        </record>
        <record id="view_project_issue_report_graph" model="ir.ui.view">
            <field name="name">project.issue.report.graph</field>
            <field name="model">project.issue.report</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph orientation="horizontal" string="Project Issue" type="bar">
                    <field name="state"/>
                    <field name="nbr" operator="+"/>
                    <field group="True" name="user_id"/>
                </graph>
            </field>
        </record>

        <record id="view_project_issue_report_filter" model="ir.ui.view">
            <field name="name">project.issue.report.select</field>
            <field name="model">project.issue.report</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search">
                  <group col="16" colspan="8">
                           <filter string="Year" icon="terp-go-year" help="Current Year"
                        domain="[('create_date','&lt;=', time.strftime('%%Y-%%m-%%d')),('create_date','&gt;=',time.strftime('%%Y-01-01'))]"
                        />

                       <filter string="Month" icon="terp-go-month" name="This Month"
                        domain="[('create_date','&lt;=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('create_date','&gt;=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
                        />
                       <filter icon="terp-go-week" string="Month-1" separator="1" help="Previous Month"
                            domain="[('create_date','&lt;=', (datetime.date.today() - relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]"
                        />

                           <separator orientation="vertical" />
                        <filter  icon="terp-camera_test"
                            string="Current"
                            domain="[('state','in',('draft','open'))]"/>
                       <filter icon="terp-gtk-media-pause"
                            string="Pending"
                            domain="[('state','=','pending')]"/>
                       <filter icon="terp-dialog-close"
                            string="Done"
                            domain="[('state','=','done')]"/>

                           <separator orientation="vertical" />
                           <field name="section_id"
                               string="Sale Team    "
                               widget="selection"
                               context="{'invisible_section': False}">

                               <filter icon="terp-crm"
                                   context="{'invisible_section': False}"
                                   domain="[('section_id.user_id','=',uid)]"
                                   help="My Sale Team" />

                           </field>
                              <field name="project_id"/>
                          <field name="user_id"  select="1" widget="selection"/>
                   </group>
                   <newline/>
                   <group expand="0" string="Extended Filters..." colspan="10" col="12" groups="base.group_extended">
                       <field name="partner_id"/>
                       <field name="assigned_to" widget="selection"/>
                       <separator orientation="vertical"/>
                       <field name="priority" />
                       <separator orientation="vertical"/>
                       <field name="version_id" widget="selection" />
                       <field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'project.issue')]"/>
                       <field name="type_id" widget="selection"/>
                       <separator orientation="vertical"/>
                       <field name="company_id" widget="selection" groups="base.group_multi_company"/>
                       <newline/>
                       <field name="creation_date"/>
                       <field name="opening_date"/>
                       <field name="date_closed" string="Date Closed"/>
                   </group>
                   <newline/>
                   <group  expand="1" string="Group By..." colspan="4" col="8">
                           <filter name="User" string="Responsible" icon="terp-personal"
                        domain="[]" context="{'group_by':'user_id'}" />
                        <filter string="Assigned to" name="Responsible" icon="terp-personal"
                        domain="[]" context="{'group_by':'assigned_to'}" />
                        <filter string="Partner" icon="terp-partner" context="{'group_by':'partner_id'}" />
                        <separator orientation="vertical" />
                        <filter string="Sale Team" icon="terp-personal+"
                            domain="[]"
                            context="{'group_by':'section_id'}" />
                        <separator orientation="vertical" />
                        <filter string="Project"  name="project" icon="terp-folder-violet" context="{'group_by':'project_id'}" />
                        <filter string="Task"  icon="terp-stock_align_left_24" domain="[]" context="{'group_by':'task_id'}"/>
                        <separator orientation="vertical" />
                        <filter string="Category" icon="terp-stock_symbol-selection"
                            domain="[]" context="{'group_by':'categ_id'}" />
                        <filter string="Version"  icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'version_id'}"/>
                        <separator orientation="vertical" />
                        <filter string="Priority"  icon="terp-rating-rated" domain="[]" context="{'group_by':'priority'}" />
                        <filter string="Stage" icon="terp-stage" domain="[]" context="{'group_by':'type_id'}"/>
                        <filter string="State" icon="terp-stock_effects-object-colorize"
                            domain="[]" context="{'group_by':'state'}" />
                        <separator orientation="vertical"/>
                        <filter string="Company" icon="terp-go-home"
                            domain="[]"
                            context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                        <separator orientation="vertical" />
                        <filter string="Day" icon="terp-go-today"
                            domain="[]" context="{'group_by':'day'}" help="Creation Date"/>

                        <filter string="Month" icon="terp-go-month"
                            domain="[]" context="{'group_by':'month'}" help="Creation Date"/>

                        <filter string="Year" icon="terp-go-year"
                            domain="[]" context="{'group_by':'name'}" help="Creation Date"/>

                  </group>
               </search>
            </field>
        </record>

        <record id="action_project_issue_report" model="ir.actions.act_window">
            <field name="name">Issues Analysis</field>
            <field name="res_model">project.issue.report</field>
            <field name="view_type">form</field>
              <field name="view_mode">graph,tree</field>
              <field name="context">{'search_default_This Month':1,'search_default_project':1,'group_by_no_leaf':1,'group_by':[]}</field>
            <field name="view_id" ref="view_project_issue_report_tree"/>
            <field name="search_view_id" ref="view_project_issue_report_filter"/>
            <field name="help">This report on the project issues allows you to analyse the quality of your support or after-sales services. You can track the issues per age. You can analyse the time required to open or close an issue, the number of email to exchange and the time spent on average by issues.</field>
        </record>


           <record model="ir.actions.act_window.view" id="action_project_issue_report_tree">
            <field name="sequence" eval="1"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_project_issue_report_tree"/>
            <field name="act_window_id" ref="action_project_issue_report"/>
        </record>
        <record model="ir.actions.act_window.view" id="action_project_issue_report_graph">
            <field name="sequence" eval="2"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="view_project_issue_report_graph"/>
            <field name="act_window_id" ref="action_project_issue_report"/>
        </record>
        <menuitem action="action_project_issue_report" id="menu_project_issue_report_tree"
            parent="base.menu_project_report"/>


  </data>
</openerp>
