<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="new_project_view" model="ir.ui.view">
            <field name="name">project.project</field>
            <field name="model">project.project</field>
            <field name="inherit_id" ref="project.edit_project"/>
            <field name="arch" type="xml">
                <xpath expr="//form[@string='Project']" position="replace" >
                  <form string="Projects">
                  <header>
                  <button name="set_open" string="Re-open project" type="object" states="pending" class="oe_highlight" groups="base.group_user"/>
                  <button name="set_done" string="Close Project" type="object" states="open,pending" groups="base.group_user"/>
                  <button name="set_open" string="Re-open project" type="object" states="cancelled,close" groups="base.group_user"/>
                  <button name="set_pending" string="Pending" type="object" states="open" groups="base.group_user"/>
                  <button name="set_cancel" string="Cancel Project" type="object" states="open,pending" groups="base.group_user"/>
                  <field name="state" widget="statusbar" statusbar_visible="open,close" statusbar_colors='{"pending":"blue"}' readonly="1"/>
              </header>
                  <sheet string="Project">
                  <div class="oe_title">
                      <label for="name" class="oe_edit_only" string="Project Name"/>
                      <h1>
                          <field name="name" string="Project Name"/>
                      </h1>
                      <div name="options_active">
                          <field name="use_tasks" class="oe_inline"/>
                          <label for="use_tasks" string="Use Tasks"/>
                      </div>
                  </div>

                  <field name="activity_ids" invisible="1"/>

                  <div class="oe_right oe_button_box" name="buttons" groups="base.group_user">
                       <button class="oe_inline oe_stat_button" type="action" attrs="{'invisible':[('use_tasks','=', 0)]}"
                          name="%(project.act_project_project_2_project_task_all)d" icon="fa-tasks">
                          <field string="Tasks" name="task_count" widget="statinfo"/>
                      </button>
                      <button  class="oe_inline oe_stat_button" name="attachment_tree_view"  type="object" icon="fa-files-o">
                          <field string="Documents" name="doc_count" widget="statinfo"/>
                      </button>
                      <button class="oe_inline oe_stat_button" type="action" attrs="{'invisible':[('activity_ids','=', [])]}" name="%(custom_project.action_activity)d"
                      context="{'search_default_project_id': active_id,'search_default_group_task_id': 1}">
                              <field string="Activities" name="progress_activities" widget="percentpie"/>
                      </button>
                  </div>
                  <group>
                      <group col="4">
                          <field name="user_id" string="Project Manager"
                                  attrs="{'readonly':[('state','in',['close', 'cancelled'])]}"
                                  context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_manager']}"/>
                          <newline/>
                      </group>
                          <!-- <p attrs="{'invisible': [('analytic_account_id','=',False)]}">
                              To invoice or setup invoicing and renewal options, go to the related contract:
                              <field name="analytic_account_id" readonly="1" required="0" class="oe_inline" nolabel="1"/>.
                          </p> -->
                  </group>
                  <notebook>
                      <page string="Team" name="team">
                          <field colspan="4" name="members" widget="many2many_kanban" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_user']}">
                              <kanban quick_create="false" create="true" delete="true">
                                  <field name="name"/>
                                  <templates>
                                      <t t-name="kanban-box">
                                          <div style="position: relative">
                                              <a t-if="! read_only_mode" type="delete" style="position: absolute; right: 0; padding: 4px; diplay: inline-block">X</a>
                                              <div class="oe_module_vignette">
                                                  <img t-att-src="kanban_image('res.users', 'image_small', record.id.value)" class="oe_avatar oe_kanban_avatar_smallbox"/>
                                                  <div class="oe_module_desc">
                                                      <field name="name"/>
                                                  </div>
                                              </div>
                                          </div>
                                      </t>
                                  </templates>
                              </kanban>
                          </field>
                      </page>
                      <page string="Other Info">
                          <group string="Miscellaneous" name="misc">
                              <field name="date_start" string="Start Date"/>
                              <field name="date" string="End Date"/>
                              <field name="sequence" groups="base.group_no_one"/>
                              <field name="active" attrs="{'invisible':[('state','in',['open', 'pending', 'template'])]}"/>
                          </group>
                      </page>
                      <page string="Project Stages" attrs="{'invisible': [('use_tasks', '=', False)]}" name="project_stages">
                           <field name="type_ids"/>
                      </page>
                  </notebook>
              </sheet>
            </form>
            </xpath>
            </field>
        </record>

        <record id="view_project_kanban" model="ir.ui.view">
             <field name="name">project.kanban</field>
             <field name="model">project.project</field>
             <field name="inherit_id" ref="project.view_project_kanban"/>
             <field name="arch" type="xml">
                 <field name="doc_count" position="after">
                     <field name="progress_activities"/>
                     <field name="activity_ids" invisible="1"/>
                 </field>
                 <div class="text-center oe_kanban_alias" position="after">
                     <div class="oe_kanban_project" style="width:130px; height: 80px; margin: 0 auto; min-height: 80px;" attrs="{'invisible':[('activity_ids', '=', [])]}">
                         <field name="progress_activities"  widget="gauge" />
                     </div>
                 </div>

             </field>
         </record>


      </data>
    </openerp>
