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

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

    <record id="crm_meeting_categ_action" model="ir.actions.act_window">
        <field name="name">Meeting 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', '=', 'crm.meeting')]</field>
        <field name="context">{'object_id':'crm.meeting'}</field>
    </record>

     <menuitem action="crm_meeting_categ_action" name="Categories of Meeting"
        id="menu_crm_case_meeting-act" parent="base.menu_calendar_configuration" sequence="1"/>

    <!-- CRM Meetings Form View -->

    <record model="ir.ui.view" id="crm_case_form_view_meet">
        <field name="name">CRM - Meetings Form</field>
        <field name="model">crm.meeting</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Meetings">
                <group col="6" colspan="4">
                    <field name="name" select="1" string="Summary"
                           required="1" />
                    <field name="categ_id" widget="selection"
                        string="Meeting Type" groups="base.group_extended"
                        domain="[('object_id.model', '=', 'crm.meeting')]" />
                    <field name="allday" on_change="onchange_allday(allday)" />
                    <newline/>
                    <field name="date" string="Start Date" required="1"
                        on_change="onchange_dates(date,duration,False,allday)" />
                    <field name="duration" widget="float_time"
                        on_change="onchange_dates(date,duration,False,allday)" />
                    <field name="date_deadline" string="End Date" required="1"
                        on_change="onchange_dates(date,False,date_deadline)" />
                    <field name="location" />
                    <field name="alarm_id" string="Reminder"
                        widget="selection" />
                    <group colspan="2" col="4" >
                           <field name="rrule_type" string="Recurrency"
                                colspan="1" attrs="{'readonly':[('recurrent_uid','!=',False)]}"/>
                           <button string="Edit All"
                               help="Edit all Ourrences of recurrent Meeting"
                               attrs="{'invisible':[('rrule_type','in', ('none', False))]}"
                               name="open_meeting" icon="gtk-edit"
                               type="object" />
                           <button string="Exclude range" groups="base.group_extended"
                                help="Add Exception Rule"
                                name="%(base_calendar.action_base_calendar_set_exrule)d" icon="gtk-zoom-out"  type="action"
                                context="{'model' : 'crm.meeting'}"
                                attrs="{'invisible':[('rrule_type','in', ('none', False))]}"/>
                    </group>
                </group>
                <group col="4" colspan="4" name="rrule" attrs="{'invisible': [('rrule_type','!=','custom')]}">
                    <separator string="Custom Recurrency Rule" colspan="8"/>
                    <group col="8" colspan="4">
                        <field name="interval" />
                        <field name="freq" />
                        <field name="count" />
                        <field name="end_date" />
                    </group>
                    <group col="14" colspan="4" name="Select weekdays"
                        attrs="{'invisible' : [('freq','!=','weekly')]}">
                        <field name="mo" colspan="1" />
                        <field name="tu" colspan="1" />
                        <field name="we" colspan="1" />
                        <field name="th" colspan="1" />
                        <field name="fr" colspan="1" />
                        <field name="sa" colspan="1" />
                        <field name="su" colspan="1" />
                        <newline />
                    </group>
                    <group col="10" colspan="4"
                        attrs="{'invisible' : [('freq','!=','monthly'), ('freq','!=','yearly')]}">
                        <group col="2" colspan="1">
                            <field name="select1" />
                        </group>
                        <group col="2" colspan="1"
                            attrs="{'invisible' : [('select1','=','day')]}">
                            <field name="day"
                                attrs="{'required' : [('select1','=','date')]}" />
                        </group>
                        <group col="3" colspan="1"
                            attrs="{'invisible' : [('select1','=','date')]}">
                            <field name="byday" string="The"
                                attrs="{'required' : [('select1','=','day')]}" />
                            <field name="week_list" nolabel="1"
                                attrs="{'required' : [('select1','=','day')]}" />
                        </group>
                        <group col="1" colspan="1"
                            attrs="{'invisible' : [('freq','!=','yearly')]}">
                            <field name="month_list" string="of"
                                colspan="1"
                                attrs="{'required' : [('freq','=','yearly')]}" />
                        </group>
                    </group>
                </group>
                <notebook colspan="4">
                <page string="Meeting">
                    <group col="6" colspan="4">
                        <group col="2" colspan="2">
                            <separator colspan="2" string="Assignment"/>
                            <field name="user_id" />
                            <field name="organizer" groups="base.group_extended"/>
                            <field name="section_id" widget="selection"
                                groups="base.group_extended"/>
                        </group><group col="2" colspan="2">
                            <separator colspan="2" string="Contacts"/>
                            <field name="partner_id" string="Partner"
                                on_change="onchange_partner_id(partner_id)" />
                            <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="2" colspan="2">
                            <separator colspan="2" string="Visibility"/>
                            <field name="class" string="Privacy"/>
                            <field name="show_as" string="Show time as" groups="base.group_extended"/>
                            <field name="rrule" invisible="1" />
                            <field name="recurrent_id" invisible="1"/>
                            <field name="recurrent_uid" invisible="1"/>
                        </group>
                    </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_close" string="Done"
                            states="open" type="object"
                            icon="gtk-jump-to" />
                        <button name="case_reset" string="Reset to Unconfirmed"
                            states="open,done,cancel" type="object"
                            icon="gtk-convert" />
                        <button name="case_open" string="Confirm"
                            states="draft" type="object"
                            icon="gtk-go-forward" />
                        <button name="case_cancel" string="Cancel"
                            states="draft,open" type="object"
                            icon="gtk-cancel" />
                    </group>
                    </page>
                    <page string="Invitation Detail">
                        <button string="Invite People"
                            name="%(base_calendar.action_view_calendar_invite_attendee_wizard)d"
                            icon="terp-partner" type="action"
                            attrs="{'readonly': [('state', '=', 'done')]}"
                            context="{'model' : 'crm.meeting', 'attendee_field':'attendee_ids'}" colspan="2"/>
                        <field name="attendee_ids" colspan="4"
                            nolabel="1" widget="one2many" mode="tree,form">
                            <tree string="Invitation details" editable="top">
                                <field name="sent_by_uid" string="From"/>
                                <field name="user_id" string="To"/>
                                <field name="email" string="Mail TO"/>
                                <field name="role" select="1" />
                                <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" />
                                <button
                                    name="%(base_calendar.action_view_calendar_invite_attendee_wizard)d"
                                    string="Delegate" type="action"
                                    icon="gtk-sort-descending"
                                    states="needs-action,tentative,declined,accepted"
                                    context="{'model' : 'calendar.attendee', 'attendee_field' : 'child_ids'}" />
                            </tree>
                            <form string="Invitation details">
                                <notebook colspan="4">
                                    <page string="Details">
                                        <field name="email" />
                                        <field name="rsvp" select="1" />
                                        <field name="cutype" select="1" />
                                        <field name="role" select="1" />
                                        <separator colspan="4" string="" />
                                        <group col="6" colspan="4">
                                            <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" />
                                            <button
                                                name="%(base_calendar.action_view_calendar_invite_attendee_wizard)d"
                                                string="Delegate"
                                                type="action"
                                                icon="gtk-sort-descending"
                                                states="needs-action,tentative,declined,accepted"
                                                context="{'model' : 'calendar.attendee', 'attendee_field' : 'child_ids'}" />
                                        </group>
                                    </page>
                                    <page string="Other">
                                        <field name="user_id"/>
                                        <field name="partner_address_id" select="1" />
                                        <newline />
                                    </page>
                                </notebook>
                            </form>
                        </field>
                    </page>
                </notebook>
            </form>
        </field>
    </record>

    <!-- CRM Meeting Tree View  -->

    <record model="ir.ui.view" id="crm_case_tree_view_meet">
        <field name="name">CRM - Meetings Tree</field>
        <field name="model">crm.meeting</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Meetings"
                colors="red:state=='open';black:state in ('draft', 'cancel','done','pending')">
                <field name="name" string="Subject" />
                <field name="date" string="Start Date" />
                <field name="duration" />
                <field name="partner_id" string="Partner" />
                <field name="location" />
                <field name="categ_id" string="Meeting Type"/>
                <field name="class" string="Privacy"/>
                <field name="state"/>
                <field name="user_id" invisible="1"/>
                <field name="show_as" invisible="1" string="Show time as"/>
                <button name="case_reset" string="Reset to Unconfirmed"
                   states="open,done,cancel" type="object"
                   icon="gtk-convert" />
                <button name="case_open" string="Confirm"
                   states="draft" type="object"
                   icon="gtk-go-forward" />
                <button name="case_close" string="Done"
                            states="open" type="object"
                            icon="gtk-jump-to" />
                <button name="case_cancel" string="Cancel"
                   states="draft,open" type="object"
                   icon="gtk-cancel" />
            </tree>
        </field>
    </record>

    <!-- CRM Meeting Calendar -->

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

    <!-- CRM Meeting Gantt  -->

    <record id="crm_case_gantt_view_meet" model="ir.ui.view">
        <field name="name">CRM - Meetings Gantt</field>
        <field name="model">crm.meeting</field>
        <field name="type">gantt</field>
        <field name="arch" type="xml">
            <gantt color="user_id" date_delay="duration" date_start="date" string="Meetings">
               <level object="crm.meeting" link="id" domain="[]">
                   <field name="name"/>
                   <field name="partner_id"/>
                </level>
            </gantt>
        </field>
    </record>

    <!-- CRM Meeting Search View  -->

    <record id="view_crm_case_meetings_filter" model="ir.ui.view">
        <field name="name">CRM - Meetings Search</field>
        <field name="model">crm.meeting</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
                <search string="Search Meetings">
                       <group col="12" colspan="4">
                           <filter icon="terp-check" name="current" string="Current"
                                domain="[('state','in',('draft', 'open'))]"
                                help="Current Meetings"/>
                           <separator orientation="vertical"/>
                           <field name="name" select="1" string="Subject"/>
                           <field name="categ_id" select="1"
                               string="Meeting Type" widget="selection"
                               domain="[('object_id.model', '=', 'crm.meeting')]" />
                           <separator orientation="vertical"/>
                           <field name="partner_id" select="1" />
                           <field name="section_id" select="1" widget="selection">
                               <filter icon="terp-personal+"
                                   domain="['|', ('section_id.user_id','=',uid), ('section_id.member_ids', 'in', [uid])]"
                                   help="My Sales Team(s)" />
                           </field>
                           <field name="user_id" select="1"/>
                       </group>
                        <newline/>
                        <group expand="0" string="Extended Options...">
                           <field name="class" select="1" string="Privacy"/>
                           <field name="show_as" string="Show time as" select="1"/>
                        </group>
                       <newline/>
                       <group expand="0" string="Group By...">
                            <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="Type" help="Meeting Type"
                            	icon="terp-stock_symbol-selection" domain="[]"
                            	context="{'group_by':'categ_id'}" />
                            <filter string="Privacy" icon="terp-locked"
                                domain="[]" context="{'group_by':'class'}" />
                            <filter string="Show time as" icon="terp-project"
                                domain="[]" context="{'group_by':'show_as'}" />
                            <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]"
                                context="{'group_by':'state'}" />
                            <separator orientation="vertical" />
                            <filter string="Date" icon="terp-go-month" help="Meeting date"
                                domain="[]" context="{'group_by':'date'}" />
                        </group>
                </search>
            </field>
        </record>

        <!-- Calendar Attendee Form View -->

        <record id="attendee_form_view_inherit" model="ir.ui.view">
                <field name="name">calendar.attendee.form.inherit</field>
                <field name="model">calendar.attendee</field>
                <field name="type">form</field>
                <field name="inherit_id" ref="base_calendar.base_calendar_attendee_form_view"/>
                <field name="arch" type="xml">
                    <field name="language" position="after">
                        <field name="categ_id" string="Event Type"/>
                    </field>
                </field>
        </record>


    </data>
</openerp>
