<?xml version="1.0"?>
<openerp>
    <data>

       <menuitem  id="menu_project_confi" name="Project Issue" parent="project.menu_definitions" sequence="2" groups="base.group_system"/>

        <record id="project_issue_categ_action" model="ir.actions.act_window">
            <field name="name">Issue Categories</field>
            <field name="res_model">crm.case.categ</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="crm.crm_case_categ_tree-view"/>
            <field name="domain">[('object_id.model', '=', 'project.issue')]</field>
            <field name="context">{'object_id':'project.issue'}</field>
        </record>

        <menuitem action="project_issue_categ_action" name="Categories" id="menu_project_issue_category_act" parent="menu_project_confi" />

        <record id="project_issue_stage_act" model="ir.actions.act_window">
            <field name="name">Issue Stages</field>
            <field name="res_model">crm.case.stage</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="crm.crm_case_stage_tree"/>
            <field name="domain">[('object_id.model', '=', 'project.issue')]</field>
            <field name="context">{'object_id':'project.issue'}</field>
        </record>

        <menuitem action="project_issue_stage_act" name="Stages" id="menu_project_issue_stage_act" parent="menu_project_confi"/>

        <record model="ir.ui.view" id="project_issue_form_view">
            <field name="name">Project Issue Tracker Form</field>
            <field name="model">project.issue</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Issue Tracker Form">
                    <group colspan="4" col="6">
                    <field name="name"/>
                    <field name="project_id" required="True"/>
                    <field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'project.issue')]"/>
                    <field name="user_id"/>
                    <field name="assigned_to" />
                        <group colspan="2" col="4">
                        <field name="stage_id" on_change="onchange_stage_id(stage_id)"  domain="[('object_id.model', '=', 'project.issue')]" widget="selection"/>
                        <button icon="gtk-go-back" string="" name="stage_previous" type="object"/>
                        <button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
                        </group>
                    </group>
                    <notebook colspan="4">
                        <page string="General">
                            <group col="2" colspan="2">
                            <separator colspan="2" string="Communication"/>
                            <field name="partner_id"  on_change="onchange_partner_id(partner_id, email_from)"/>
                            <field name="partner_address_id"  string="Contact" on_change="onchange_partner_address_id(partner_address_id, email_from)"/>
                            <field name="email_from"/>
                            </group>
                            <group col="3" colspan="2">
                            <separator colspan="3" string="Status"/>
                            <field name="type_id" colspan="3"/>
                            <field name="priority" colspan="3"/>
                            <field name="task_id" />
                            <button string="Convert To Task" name="convert_issue_task" icon="gtk-index" type="object"
                                attrs="{'invisible':[('task_id','!=',False)]}" />
                            </group>
                            <separator string= "Description" colspan="4"/>
                            <field name="description" nolabel="1" colspan="4"/>
                            <separator colspan="4"/>
                            <group col="8" colspan="4">
                            <field name="state" />
                            <button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
                            <button name="case_close" string="Close" states="open,draft,pending" type="object" icon="terp-dialog-close"/>
                            <button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
                            <button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
                            <button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
                            <button name="case_reset" string="Reset to Draft" states="done,cancel" type="object" icon="gtk-convert"/>
                            </group>
                        </page>
                        <page string="Emails" groups="base.group_extended">
                            <group colspan="4">
                            <field colspan="4" name="email_cc" string="Global CC" widget="url"/>
                            </group>
                            <field name="message_ids" colspan="4" nolabel="1" mode="tree,form">
                                <tree string="History">
                                    <field name="display_text" string="History Information"/>
                                    <field name="history" invisible="1"/>
                                    <button
                                        string="Reply" attrs="{'invisible': [('history', '!=', True)]}"
                                        name="%(crm.action_crm_send_mail)d"
                                        context="{'mail':'reply', 'model': 'project.issue', 'include_original' : True}"
                                        icon="terp-mail-replied" type="action" />
                                </tree>
                                <form string="History">
                                    <group col="4" colspan="4">
                                        <field name="email_from"/>
                                        <field name="date"/>
                                        <field name="email_to" widget="char" size="512"/>
                                        <field name="email_cc" widget="char" size="512"/>
                                        <field name="name" colspan="4" widget="char" size="512"/>
                                        <field name="history" invisible="1"/>
                                    </group>
                                    <notebook colspan="4">
                                        <page string="Details">
                                            <group attrs="{'invisible': [('history', '!=', True)]}">
                                                <field name="description" colspan="4" nolabel="1" height="250"/>
                                                <button colspan="4"
                                                    string="Reply"
                                                    name="%(crm.action_crm_send_mail)d"
                                                    context="{'mail':'reply', 'model': 'project.issue', 'include_original' : True}"
                                                    icon="terp-mail-replied" type="action" />
                                            </group>
                                            <group attrs="{'invisible': [('history', '=', True)]}">
                                                <field name="display_text" colspan="4" nolabel="1"  height="250"/>
                                            </group>
                                        </page>
                                        <page string="Attachments">
                                            <field name="attachment_ids" colspan="4" readonly="1" nolabel="1"/>
                                        </page>
                                    </notebook>
                                </form>
                            </field>
                           <separator colspan="4"/>
                            <button string="Add Internal Note"
                                name="%(crm.action_crm_add_note)d"
                                context="{'model': 'crm.lead' }"
                                icon="terp-document-new" type="action" />
                            <button string="Send New Email"
                               name="%(crm.action_crm_send_mail)d"
                               context="{'mail':'new', 'model': 'project.issue'}"
                               icon="terp-mail-message-new" type="action" />
                        </page>
                           <page string="History" groups="base.group_extended">
                            <group col="2" colspan="2">
                            <separator colspan="2" string="Date"/>
                            <field name="create_date"/>
                            <field name="write_date" />
                            <field name="date_closed"/>
                            <field name="date_open"/>
                            </group>
                            <group colspan="2" col="2">
                            <separator string="Statistics" colspan="2" col="2"/>
                            <field name="day_open"/>
                            <field name="day_close"/>
                            <field name="working_hours_open" widget="float_time"/>
                            <field name="working_hours_close" widget="float_time"/>
                            </group>
                            <group colspan="2" col="2">
                            <separator string="References" colspan="2"/>
                            <field name="id"/>
                            <field name="active"/>
                            </group>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="project_issue_tree_view">
            <field name="name">Project Issue Tracker Tree</field>
            <field name="model">project.issue</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Issue Tracker Tree" colors="black:state=='open';blue:state=='pending';grey:state in ('cancel', 'done')">
                    <field name="id"/>
                    <field name="create_date"/>
                    <field name="name"/>
                    <field name="partner_id"/>
                    <field name="project_id" />
                    <field name="priority" string="Priority"/>
                    <field name="stage_id" string="Resolution"/>
                    <button icon="gtk-go-back" string="" name="stage_previous" type="object"
                        states="open,draft,pending,done,cancel" />
                    <button icon="gtk-go-forward" string="" name="stage_next" type="object"
                        states="open,draft,pending,done,cancel" />
                    <field name="type_id" string="Version"/>
                    <field name="user_id"/>
                    <field name="assigned_to"/>
                    <field name="state"/>
                    <button name="case_close" string="Done" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
                    <button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward" help="To Do"/>
                    <button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
                    <button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
                    <button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
                    <button name="case_reset" string="Reset to Draft" states="done,cancel" type="object" icon="gtk-convert"/>
                    <field name="categ_id" invisible="1"/>
                </tree>
            </field>
        </record>

        <record id="view_project_issue_filter" model="ir.ui.view">
            <field name="name">Project Issue Tracker Search</field>
            <field name="model">project.issue</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Issue Tracker Search">
                    <group>
                        <filter string="Current" name="current" domain="[('state','in',('open','draft'))]" help="Draft and To Do" icon="terp-check" default="1"/>
                        <filter string="To Do" domain="[('state','=','open')]" help="To Do Issues" icon="terp-camera_test"/>
                        <filter string="Pending" domain="[('state','=','pending')]"  help="Pending Issues" icon="terp-gtk-media-pause"/>
                        <separator orientation="vertical"/>
                        <filter icon="terp-go-today" string="   Today   " separator="1" domain="[('date','=',time.strftime('%%Y-%%m-%%d'))]" help="Today's bugs" />
                        <filter icon="terp-go-week" string="    7 Days    " separator="1"
                            domain="[('date','&lt;', time.strftime('%%Y-%%m-%%d')), ('date', '&gt;=', (datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
                            help="Bugs during last 7 days"
                            />
                        <separator orientation="vertical"/>
                        <field name="name" string="Name"/>
                        <field name="user_id"/>
                        <field name="project_id" string="Project"/>
                        <field name="state"/>
                        <field name="categ_id"/>
                    </group>
                    <newline/>
                    <group expand="0" string="Group By..."  groups="base.group_extended">
                    	<filter string="Responsible" icon="terp-personal"
                            domain="[]" context="{'group_by':'user_id'}" />
                    	<filter string="Partner" icon="terp-partner" domain="[]"
                            context="{'group_by':'partner_id'}" />
						<separator orientation="vertical"/>
                        <filter string="Project"  icon="terp-folder-blue" domain="[]"
                            context="{'group_by':'project_id'}" />
                        <filter string="Version" icon="terp-gtk-jump-to-rtl"
                            domain="[]" context="{'group_by':'type_id'}" />
						<separator orientation="vertical"/>
						<filter string="Category" icon="terp-stock_symbol-selection" domain="[]"
                            context="{'group_by':'categ_id'}" />
						<filter string="Priority" icon="terp-rating-rated" domain="[]"
                            context="{'group_by':'priority'}" />
                        <filter string="Stage" icon="terp-stage" domain="[]"
                            context="{'group_by':'stage_id'}" />
                        <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]"
                            context="{'group_by':'state'}" />
                        <separator orientation="vertical" />
                        <filter string="Month" icon="terp-go-month"
                            domain="[]" context="{'group_by':'create_date'}" help="Creation Month"/>
                    </group>
                </search>
            </field>
        </record>

        <record model="ir.ui.view" id="project_issue_calendar_view">
            <field name="name">Project Issue Tracker Calendar</field>
            <field name="model">project.issue</field>
            <field name="type">calendar</field>
            <field name="priority" eval="2"/>
            <field name="arch" type="xml">
                <calendar string="Issues" date_start="date" color="user_id" date_delay="duration">
                    <field name="name"/>
                    <field name="partner_id"/>
                </calendar>
            </field>
        </record>

        # ------------------------------------------------------
        # Feature Requests
        # ------------------------------------------------------

        <record model="ir.ui.view" id="project_feature_tree_view">
            <field name="name">Project Issue- Feature Tracker Tree</field>
            <field name="model">project.issue</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Feature Tracker Tree"  colors="red:state=='open';black:state in ('draft', 'cancel','done','pending')">
                    <field name="id"/>
                    <field name="name" string="Feature description"/>
                    <field name="partner_id"/>
                    <field name="priority" string="Priority"/>
                    <field name="stage_id" string="Resolution"/>
                    <button icon="gtk-go-back" string="" name="stage_previous" type="object"
                        states="open,draft,pending,done,cancel" />
                    <button icon="gtk-go-forward" string="" name="stage_next" type="object"
                        states="open,draft,pending,done,cancel" />
                    <field name="type_id" string="Version"/>
                    <field name="user_id"/>
                    <field name="state"/>
                    <button name="case_close" string="Done" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
                    <button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
                    <button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
                    <button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
                    <button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
                    <button name="case_reset" string="Reset to Draft" states="done,cancel" type="object" icon="gtk-convert"/>
                </tree>
            </field>
        </record>

        <record id="view_project_feature_filter" model="ir.ui.view">
            <field name="name">Project Issue- Feature Tracker Search</field>
            <field name="model">project.issue</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Feature Tracker Search">
                    <group>
                        <filter icon="terp-go-today" string="   Today   " separator="1"
                            domain="[('date','=',time.strftime('%%Y-%%m-%%d'))]" help="Today's features"/>
                        <filter icon="terp-go-week" string="    7 Days    " separator="1"
                            domain="[('date','&lt;', time.strftime('%%Y-%%m-%%d')), ('date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]" help="Features during last 7 days"/>
                    </group>
                    <separator orientation="vertical"/>
                    <group>
                        <field name="name" select='1' string="Feature description"/>
                        <field name="user_id" select="1"/>
                        <field name="state" select="1">
                            <filter icon="terp-check" domain="[('state','in',('open','draft'))]" help="Current Features" name="current_feature"/>
                            <filter icon="terp-camera_test" domain="[('state','=','open')]" help="Open Features"/>
                        </field>
                        <field name="project_id" select="1" string="Project"/>
                    </group>
                </search>
            </field>
        </record>

	# ------------------------------------------------------
    # Project
    # ------------------------------------------------------

        <record id="view_project_form_inherited" model="ir.ui.view">
            <field name="name">project.project.form.inherited</field>
            <field name="model">project.project</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="project.edit_project"/>
            <field name="arch" type="xml">
                <field name="priority" position="before">
                    <field name="resource_calendar_id"/>
                    <field name="project_escalation_id"/>
                    <field name="reply_to"/>
                </field>
            </field>
       </record>

    </data>
</openerp>
