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


    <!-- CRM Meetings Types Form View -->

    <record id="view_crm_meeting_type_tree" model="ir.ui.view">
        <field name="name">Meeting Types Tree</field>
        <field name="model">crm.meeting.type</field>
        <field name="arch" type="xml">
            <tree string="Meeting Types" editable="bottom">
                <field name="name"/>
            </tree>
        </field>
    </record>

    <record id="action_crm_meeting_type" model="ir.actions.act_window">
        <field name="name">Meeting Types</field>
        <field name="res_model">crm.meeting.type</field>
        <field name="view_type">form</field>
        <field name="view_id" ref="view_crm_meeting_type_tree"/>
    </record>

    <menuitem id="menu_crm_meeting_type" parent="base.menu_calendar_configuration" sequence="1"
        action="action_crm_meeting_type" groups="base.group_no_one"/>

    <!-- CRM Meetings Form View -->

    <record model="ir.ui.view" id="view_crm_meeting_form">
        <field name="name">CRM - Meetings Form</field>
        <field name="model">crm.meeting</field>
        <field name="arch" type="xml">
            <form string="Meetings" version="7.0">
                <field name="state" invisible="True"/>
                <sheet>
                    <div class="oe_title">
                        <div class="oe_edit_only">
                            <label for="name"/>
                        </div>
                        <h1>
                            <field name="name"/>
                        </h1>
                        <label for="partner_ids" class="oe_edit_only"/>
                        <h2>
                            <field name="partner_ids" widget="many2many_tags"
                                context="{'force_email':True}"
                                on_change="onchange_partner_ids(partner_ids)"/>
                        </h2>
                    </div>
                    <notebook>
                    <page string="Meeting Details">
                        <group>
                            <group>
                                <field name="date" string="Starting at"
                                    on_change="onchange_dates(date, duration, False, allday)"/>
                                <label for="duration"/>
                                <div>
                                    <field name="duration" widget="float_time"
                                        on_change="onchange_dates(date,duration,False,allday)"
                                        class="oe_inline" attrs="{'invisible': [('allday','=',True)]}"/>
                                    <label string="hours" attrs="{'invisible': [('allday','=',True)]}"/>
                                    (<field name="allday" on_change="onchange_dates(date,False,False,allday)" class="oe_inline"/>
                                    <label for="allday" string="All Day?"/>)
                                </div>
                                <field name="date_deadline" groups="base.group_no_one"
                                    attrs="{'invisible': ['|', ('allday','=',True), ('duration','&lt;', 24)]}"
                                    on_change="onchange_dates(date,False,date_deadline)"/>
                            </group>
                            <group>
                                <field name="user_id" groups="base.group_no_one"/>
                                <field name="categ_ids" widget="many2many_tags"/>
                                <field name="location"/>
                                <field name="organizer" groups="base.group_no_one"/>
                            </group>

                        </group>
                        <label for="description"/>
                        <field name="description"/>
                    </page>
                    <page string="Options">
                        <group>
                            <group col="1">
                                <group>
                                    <field name="recurrency"/>
                                </group>
                                <group attrs="{'invisible': [('recurrency','=',False)]}">
                                    <label for="interval"/>
                                    <div>
                                        <field name="interval" attrs="{'required': [('recurrency','==',True)]}" class="oe_inline"/>
                                        <field name="rrule_type" attrs="{'required': [('recurrency','==',True)]}" class="oe_inline"/>
                                    </div>
                                    <label string="Until" for="end_type"/>
                                    <div>
                                        <field name="end_type" attrs="{'required': [('recurrency','==',True)]}" class="oe_inline"/>
                                        <field name="count" attrs="{'invisible': [('end_type', '!=', 'count')], 'required': [('recurrency','==',True)]}" class="oe_inline"/>
                                        <field name="end_date" attrs="{'invisible': [('end_type', '!=', 'end_date')], 'required': [('end_type', '=', 'end_date')]}" class="oe_inline"/>
                                    </div>
                                    <label string="Select Weekdays" attrs="{'invisible' :[('rrule_type','not in', ['weekly'])]}"/>
                                    <group col="2" colspan="1" name="weekdays" attrs="{'invisible' :[('rrule_type','not in', ['weekly'])]}">
                                        <field name="mo"/>
                                        <field name="tu"/>
                                        <field name="we"/>
                                        <field name="th"/>
                                        <field name="fr"/>
                                        <field name="sa"/>
                                        <field name="su"/>
                                    </group>

                                    <label string="Day of Month"
                                        attrs="{'invisible': [('rrule_type','!=','monthly')]}"/>

                                    <div attrs="{'invisible': [('rrule_type','!=','monthly')]}">
                                        <field name="select1"/>
                                        <field name="day"
                                            attrs="{'required': [('select1','=','date'), ('rrule_type','=','monthly')],
                                                'invisible': [('select1','=','day')]}"/>
                                        <field name="byday" string="The"
                                            attrs="{'required': [('select1','=','day'), ('rrule_type','=','monthly')], 'invisible': [('select1','=','date')]}"/>
                                        <field name="week_list" nolabel="1"
                                            attrs="{'required': [('select1','=','day'), ('rrule_type','=','monthly')], 'invisible': [('select1','=','date')]}"/>
                                    </div>

                                </group>
                            </group>
                            <group>
                                <field name="alarm_id" widget="selection" groups="base.group_no_one"/>
                                <field name="class"/>
                                <field name="show_as"/>
                                <field name="rrule" invisible="1" readonly="1"/>
                                <field name="recurrent_id_date" invisible="1"/>
                                <field name="recurrent_id" invisible="1"/>
                            </group>
                        </group>
                    </page>
                    <page string="Invitations">
                        <field name="attendee_ids" widget="one2many" mode="tree">
                            <tree string="Invitation details" editable="top">
                                <field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
                                <field name="email" string="Mail To"/>
                                <field name="state"/>
                                <button name="do_tentative"
                                    states="needs-action,declined,accepted"
                                    string="Uncertain" type="object"
                                    icon="terp-crm"/>
                                <button name="do_accept" string="Accept"
                                    states="needs-action,tentative,declined"
                                    type="object" icon="gtk-apply"/>
                                <button name="do_decline" string="Decline"
                                    states="needs-action,tentative,accepted"
                                    type="object" icon="gtk-cancel"/>
                            </tree>
                            <form string="Invitation details" version="7.0">
                                <header>
                                    <button name="do_tentative" type="object"
                                        states="needs-action,declined,accepted"
                                        string="Uncertain"/>
                                    <button name="do_accept" type="object"
                                        states="needs-action,tentative,declined"
                                        string="Accept"/>
                                    <button name="do_decline" type="object"
                                        states="needs-action,tentative,accepted"
                                        string="Decline"/>
                                    <field name="state" widget="statusbar" statusbar_visible="draft,open,done"/>
                                </header>
                                <group>
                                    <group>
                                        <field name="email"/>
                                        <field name="rsvp"/>
                                        <field name="cutype"/>
                                        <field name="role"/>
                                    </group>
                                    <group>
                                        <field name="partner_id"/>
                                        <field name="user_id"/>
                                    </group>
                                </group>
                            </form>
                        </field>
                    </page>

                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <!-- CRM Meeting Tree View  -->

    <record model="ir.ui.view" id="view_crm_meeting_tree">
        <field name="name">CRM - Meetings Tree</field>
        <field name="model">crm.meeting</field>
        <field name="arch" type="xml">
            <tree string="Meetings" fonts="bold:message_unread==True">
                <field name="name" string="Subject"/>
                <field name="user_id"/>
                <field name="date"/>
                <field name="state" invisible="True"/>
                <field name="duration"/>
                <field name="message_unread" invisible="1"/>
            </tree>
        </field>
    </record>

    <!-- CRM Meeting Calendar -->

    <record model="ir.ui.view" id="view_crm_meeting_calendar">
        <field name="name">CRM - Meetings Calendar</field>
        <field name="model">crm.meeting</field>
        <field name="priority" eval="2"/>
        <field name="arch" type="xml">
            <calendar string="Meetings" date_start="date" color="user_id" date_stop="date_deadline" date_delay="duration">
                <field name="name"/>
                <field name="user_id"/>
            </calendar>
        </field>
    </record>

    <!-- CRM Meeting Gantt  -->

    <record id="view_crm_meeting_gantt" model="ir.ui.view">
        <field name="name">CRM - Meetings Gantt</field>
        <field name="model">crm.meeting</field>
        <field name="arch" type="xml">
            <gantt date_delay="duration" date_start="date" string="Meetings"/>
        </field>
    </record>

    <!-- CRM Meeting Search View  -->

    <record id="view_crm_meeting_search" model="ir.ui.view">
        <field name="name">CRM - Meetings Search</field>
        <field name="model">crm.meeting</field>
        <field name="arch" type="xml">
            <search string="Search Meetings">
                <field name="name" string="Meeting" filter_domain="[('name','ilike',self)]"/>
                <field name="partner_ids"/>
                <field name="categ_ids"/>
                <field name="user_id"/>
                <separator/>
                <filter string="My Meetings" help="My Meetings" domain="[('user_id','=',uid)]"/>
                <filter string="Unread Messages" name="message_unread" domain="[('message_unread','=',True)]"/>
            </search>
        </field>
    </record>

    <!-- CRM Meetings action and menu -->

    <record id="action_crm_meeting" model="ir.actions.act_window">
        <field name="name">Meetings</field>
        <field name="res_model">crm.meeting</field>
        <field name="view_mode">calendar,tree,form,gantt</field>
        <field name="view_id" ref="view_crm_meeting_calendar"/>
        <field name="search_view_id" ref="view_crm_meeting_search"/>
        <field name="context">{"calendar_default_user_id": uid}</field>
        <field name="help" type="html">
          <p class="oe_view_nocontent_create">
            Click to schedule a new meeting.
          </p><p>
            The calendar 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_view_crm_meeting_calendar">
        <field name="act_window_id" ref="action_crm_meeting"/>
        <field name="sequence" eval="1"/>
        <field name="view_mode">calendar</field>
        <field name="view_id" ref="view_crm_meeting_calendar"/>
    </record>
    <record model="ir.actions.act_window.view" id="action_view_crm_meeting_tree">
        <field name="act_window_id" ref="action_crm_meeting"/>
        <field name="sequence" eval="2"/>
        <field name="view_mode">tree</field>
        <field name="view_id" ref="view_crm_meeting_tree"/>
    </record>
    <record model="ir.actions.act_window.view" id="action_view_crm_meeting_form">
        <field name="act_window_id" ref="action_crm_meeting"/>
        <field name="sequence" eval="3"/>
        <field name="view_mode">form</field>
        <field name="view_id" ref="view_crm_meeting_form"/>
    </record>
    <record model="ir.actions.act_window.view" id="action_view_crm_meeting_gantt">
        <field name="act_window_id" ref="action_crm_meeting"/>
        <field name="sequence" eval="4"/>
        <field name="view_mode">gantt</field>
        <field name="view_id" ref="view_crm_meeting_gantt"/>
    </record>

    <menuitem name="Calendar"
        id="mail_menu_calendar" parent="mail.mail_my_stuff"
        sequence="10" action="action_crm_meeting"/>

    </data>
</openerp>
