<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record id="view_project_task_activity_search" model="ir.ui.view">
      <field name="name">project.task_activity.search</field>
      <field name="model">project.task.activity</field>
      <field name="arch" type="xml">
        <search string="Activity">
          <field name="name"/>
          <field name="user_id"/>
          <field name="task_id"/>
          <field name="project_id"/>
          <field name="company_id"/>
          <field name="state"/>
          <filter string="Realizado" domain="[('state', '=', 'done')]"/>
          <filter string="Pendiente" domain="[('state', '=', 'pending')]"/>
          <filter string="Cancelado" domain="[('state', '=', 'cancel')]"/>
        <br/>
          <filter string="Creado hoy" domain="[('planned_date', '&gt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),('planned_date', '&lt;=',datetime.datetime.now().strftime('%Y-%m-%d 23:23:59'))]"/>
          <filter string="Finalizado hoy" domain="[('done_date', '&gt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),('done_date', '&lt;=',datetime.datetime.now().strftime('%Y-%m-%d 23:23:59'))]"/>
          <group expand="0" string="Group By..">
            <filter string="Project" help="Proyecto" context="{'group_by':'project_id'}"/>
            <filter string="Estado" help="Estado" context="{'group_by':'state'}"/>
            <filter string="Responsable" help="Responsable" context="{'group_by':'user_id'}"/>
          </group>
        </search>
      </field>
    </record>

    <record id="view_project_task_activity_form" model="ir.ui.view">
      <field name="name">project.task_activity.form</field>
      <field name="model">project.task.activity</field>
      <field name="arch" type="xml">
        <form>
          <group>
            <field name="name"/>
            <field name="user_id" required="True"/>
            <field name="planned_date"/>
            <field name="done_date"/>
            <field name="duration"/>
          </group>
          <group>
            <field name="task_id"/>
            <field name="project_id"/>
            <field name="company_id"/>
            <field name="state"/>
            <field name="description"/>
          </group>
        </form>
      </field>
    </record>

    <record id="view_project_task_activity_calendar" model="ir.ui.view">
      <field name="name">Calendario de Actividades</field>
      <field name="model">project.task.activity</field>
      <field eval="2" name="priority"/>
      <field name="arch" type="xml">
        <calendar color="user_id" date_start="planned_date" date_stop="done_date" string="Actividades" event_open_popup="%(view_project_task_activity_form)s">
          <field name="name"/>
          <field name="hex_value"/>
        </calendar>
      </field>
    </record>

    <record id="view_project_task_activity_tree" model="ir.ui.view">
      <field name="name">project.task_activity.tree</field>
      <field name="model">project.task.activity</field>
      <field name="arch" type="xml">
        <tree colors="gray:state == 'cancel';blue:state == 'pending'">
          <field name="name"/>
          <field name="user_id"/>
          <field name="planned_date"/>
          <field name="done_date"/>
          <field name="state"/>
          <field name="description"/>
        </tree>
      </field>
    </record>
    <record id="activity_calendar" model="ir.actions.act_window">
      <field name="name">Actividades</field>
      <field name="res_model">project.task.activity</field>
      <field name="view_mode">calendar,form,tree</field>
      <field name="view_id" ref="view_project_task_activity_calendar"/>
      <field name="help" type="html">
        <p class="oe_view_nocontent_create">
          Click to schedule a new meeting.
        </p>
        <p>
          The calendario is shared between employees and fully integrated with other applications such as the employee holidays or the business opportunities.
        </p>
      </field>
    </record>

    <record model="ir.actions.act_window.view" id="action_calendar_activity">
      <field name="act_window_id" ref="activity_calendar"/>
      <field name="sequence" eval="1"/>
      <field name="view_mode">calendar</field>
      <field name="view_id" ref="view_project_task_activity_calendar"/>
    </record>

    <record model="ir.actions.act_window.view" id="action_calendar_form">
      <field name="act_window_id" ref="activity_calendar"/>
      <field name="sequence" eval="3"/>
      <field name="view_mode">form</field>
      <field name="view_id" ref="view_project_task_activity_form"/>
    </record>

    <record model="ir.actions.act_window.view" id="action_calendar_tree">
      <field name="act_window_id" ref="activity_calendar"/>
      <field name="sequence" eval="3"/>
      <field name="view_mode">tree</field>
      <field name="view_id" ref="view_project_task_activity_tree"/>
    </record>

    <menuitem name="Calendario de Actividades" id="mail_menu_calendario" parent="mail.mail_my_stuff" sequence="10" action="activity_calendar"/>

  </data>
</openerp>
