<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<object-views xmlns="http://axelor.com/xml/ns/object-views"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://axelor.com/xml/ns/object-views http://axelor.com/xml/ns/object-views/object-views_5.2.xsd">
    
    <grid name="event-grid" title="Events" model="com.axelor.apps.crm.db.Event" orderBy="-startDateTime">
    	<hilite color="primary" if="statusSelect == 1 &amp;&amp; startDateTime  &lt;= __datetime__"/>
    	<hilite color="warning" if="statusSelect == 1 &amp;&amp; startDateTime  &gt; __datetime__"/>
    	<hilite color="success" if="statusSelect == 2"/>
    	<hilite color="danger" if="statusSelect == 3"/>
    	<field name="startDateTime"/>
    	<field name="partner" />
    	<field name="lead" />
    	<field name="typeSelect"/>
    	<field name="subject"/>
        <field name="statusSelect" />
        <field name="user" form-view="user-form"  grid-view="user-grid"/>
    </grid>

    <grid name="list-event-grid" title="Events" model="com.axelor.apps.crm.db.Event" orderBy="-startDateTime"  x-row-height="80">
		<field name="typeSelect"/>
		<field name="statusSelect" />
		<field name="startDateTime"/>
		<field name="user"/>
		<field name="subject"/>
		<field name="description" widget="html"/>
	</grid>
    
    <calendar name="event-calendar-color-by-user" title="Meetings" mode="month" colorBy="user"
    	eventStart="startDateTime" eventStop="endDateTime" eventLength="1" model="com.axelor.apps.crm.db.Event"
    	onChange="action-event-method-compute-from-calendar">
    	<field name="subjectTeam" />
 	</calendar>
 	
 	<calendar name="event-calendar-color-by-calendar" title="My Calendar" mode="month" colorBy="typeSelect" 
    	eventStart="startDateTime" eventStop="endDateTime" eventLength="1" model="com.axelor.apps.crm.db.Event"
    	onChange="action-event-method-compute-from-calendar">
    	<field name="subject" />
 	</calendar>
    
    <grid name="my-event-grid" orderBy="-startDateTime" title="Events" model="com.axelor.apps.crm.db.Event">
    	<hilite color="primary" if="statusSelect == 1 &amp;&amp; startDateTime  &lt;= __datetime__"/>
    	<hilite color="info" if="statusSelect == 1 &amp;&amp; startDateTime  &gt; __datetime__"/>
    	<hilite color="success" if="statusSelect == 2"/>
    	<hilite color="danger" if="statusSelect == 3"/>
		<field name="startDateTime"/>
		<field name="subject"/>
		<field name="typeSelect"/>
		<field name="duration" widget="duration" x-big="true"/>
	</grid>

    <grid name="lead-event-grid" title="Events" model="com.axelor.apps.crm.db.Event" orderBy="-startDateTime">
    	<hilite color="primary" if="statusSelect == 1 &amp;&amp; startDateTime  &lt;= __datetime__"/>
    	<hilite color="info" if="statusSelect == 1 &amp;&amp; startDateTime  &gt; __datetime__"/>
    	<hilite color="success" if="statusSelect == 2"/>
    	<hilite color="danger" if="statusSelect == 3"/>
    	<field name="startDateTime" />
		<field name="subject" />
		<field name="user" />
		<field name="description" />
    </grid>
    
	<form name="event-form" title="Events" model="com.axelor.apps.crm.db.Event"
	onLoad="action-group-crm-event-onload" onNew="action-group-crm-event-onnew" onSave="action-event-group-on-save">
		<toolbar>
			<button name="grabEventBtn" icon="fa-suitcase" help="Take charge" onClick="save,action-method-crm-event-assign-tome" showIf="typeSelect == 1"/>
			<button name="viewOnMapBtn" icon="fa-map-marker" onClick="com.axelor.apps.crm.web.EventController:viewMap" showIf="typeSelect == 2"/>
			<button name="startBtn" readonlyIf="statusSelect == 12 || statusSelect == 14" icon="fa-play"  showIf="typeSelect == 3" onClick="action-set-task-status-select-2,save"/>
			<button name="pauseBtn" readonlyIf="statusSelect == 14 || statusSelect == 13" icon="fa-pause" showIf="typeSelect == 3" onClick="action-set-task-status-select-3,save"/>
			<button name="acceptBtn" readonlyIf="statusSelect == 14" icon="fa-power-off" showIf="typeSelect == 3" onClick="action-set-task-status-select-4,save"/>
		</toolbar>
		<menubar>
			<menu name="eventToolsMenu" title="Tools" icon="fa-wrench" showTitle="true">
			  <item name="createOpportunityItem" title="Create opportunity" action="save,action-event-view-create-opportunity"/>
			  <item name="createEventItem" title="Create event" action="save,action-event-view-create-event"/>
			</menu>
		</menubar>
		<panel colSpan="12" name="meetingGeneralPanel">
			<field name="typeSelect" domain="self.value IN ('0','1','2','3')" showTitle="false" colSpan="3" onChange="action-event-type-select-onchange-group">
	        	<viewer depends="typeSelect"><![CDATA[
	           		<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.typeSelect == 0" x-translate>Event</span>
	          		<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.typeSelect == 1" x-translate>Call</span>
	          		<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.typeSelect == 2" x-translate>Meeting</span>
	          		<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.typeSelect == 3" x-translate>Task</span>
	       		 ]]>
	        	</viewer>
	      	</field>
			<field name="statusSelect" showTitle="false" colSpan="3" selection-in="[1, 2, 3]" showIf="typeSelect == 1 || typeSelect == 2 || typeSelect == 0" >
	        	<viewer depends="statusSelect"><![CDATA[
	           		<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.statusSelect == 1" x-translate>Planned</span>
	          		<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.statusSelect == 2" x-translate>Realized</span>
	          		<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.statusSelect == 3" x-translate>Canceled</span>
	       		 ]]>
	        	</viewer>
        	</field>
			<field name="statusSelect" showTitle="false" colSpan="3" selection-in="[11, 12, 13, 14, 15]" showIf="typeSelect == 3">
				<viewer depends="statusSelect"><![CDATA[
					<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.statusSelect == 11" x-translate>Not started</span>
					<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.statusSelect == 12" x-translate>On going</span>
					<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.statusSelect == 13" x-translate>Pending</span>
					<span class="label label-default" style="background-color: #0285D8; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.statusSelect == 14" x-translate>Finished</span>
					<span class="label label-default" style="background-color: #D9534F; margin: 0px 0 !important; display: inline-table; line-height: initial;" ng-show="record.statusSelect == 15" x-translate>Reported</span>
				]]>
				</viewer>
			</field>
			<field name="subject" showTitle="false" colSpan="12">
				<viewer depends="subject">
				<![CDATA[
					<h3>
						<span  style="margin: 5px 0 !important; display: inline-table; line-height: initial;">{{record.subject}}</span>
					</h3>
				]]>
				</viewer>
				<editor>
					<field name="subject" showTitle="true" colSpan="12"/>
				</editor>
			</field>
			<field name="startDateTime" colSpan="3" onChange="action-event-method-compute-from-start-date-time"/>
			<field name="endDateTime" colSpan="3" onChange="action-event-method-compute-from-end-date-time"/>
			<field name="allDay" colSpan="2"/>
			<field name="duration" widget="duration" colSpan="2" onChange="action-event-method-compute-from-duration" x-big="true" hidden="true"/>
			<static name="pastEventText" hidden="true" showIf="id &amp;&amp; $moment(startDateTime) &lt; $moment(todayDate)" colSpan="12"><![CDATA[<span class='label label-warning'>The selected date is in the past.</span>]]></static>
		</panel>

		<panel-tabs name="mainPanelTab">
			<panel name="descriptionPanel" title="Description">
				<field name="description" showTitle="false" widget="html" colSpan="12"/>
			</panel>
			<panel name="organizationPanel" title="Organization">
				<field name="location" css="highlight"/>
				<field name="geo" colSpan="5"/>
				<button name="viewOnMapBtn" colSpan="1" icon="fa-map-marker" onClick="com.axelor.apps.crm.web.EventController:viewMap"/>
				<field name="organizer"/>
			</panel>
			<panel name="informationPanel" title="Information">
				<field name="visibilitySelect" readonlyIf="calendar != null"/>
				<field name="disponibilitySelect" readonlyIf="calendar != null"/>
				<field name="status"/>
				<field name="subjectTeam" hidden="true"/>
				<field name="computedAttendeeList" hidden="true"/>
			</panel>
			<panel name="eventRemindersPanel" title="Reminders">
				<button name="addReminderButton" title="Create a new reminder" onClick="save,action-crm-event-reminder-view-create-reminder" colSpan="4" colOffset="4"/>
				<panel-dashlet name="eventReminderListPanel" action="action-crm-event-reminder-view-active-user-reminders" colSpan="12"/>
			</panel>
		</panel-tabs>

		<panel title="Guests" name="addGuestsPanel" sidebar="true" canCollapse="true">
			<field name="$guestEmail" title="Add a guest" colSpan="12" type="many-to-one" target="com.axelor.apps.message.db.EmailAddress" canNew="true" onChange="action-event-method-add-email-guest"/>
			<field name="attendees" canNew="false" canSelect="false" colSpan="12" showTitle="false">
				<editor layout="table" x-show-titles="false">
					<field name="name" readonly="true" />
					<field name="statusSelect" />
				</editor>
			</field>
		</panel>

		<panel sidebar="true" name="followupPanel" title="Follow up" canCollapse="true">
			<field name="user" canNew="false" canEdit="false" canView="false" form-view="user-form" grid-view="user-grid" colSpan="6"/>
			<field name="calendar" widget="SuggestBox" onSelect="action-event-method-domain-calendar" onChange="action-event-method-change-creator" colSpan="6"/>
			<field name="team" canEdit="false" onSelect="action-event-attrs-team-domain" form-view="team-form" grid-view="team-grid" if="__config__.app.getApp('base').getTeamManagement()"/>
		</panel>

		<panel sidebar="true" title="Characteristics" name="meetingAttributesPanel" canCollapse="true">
			<field name="recurrenceConfiguration" title="Recurrence" canNew="true" canSelect="false" onChange="save, action-event-method-generate-recurrence" colSpan="12"/>
			<field name="eventCategory" canEdit="false" domain="self.typeSelect = :typeSelect" colSpan="6"/>
			<field name="callTypeSelect"  showIf="typeSelect == 1" colSpan="6"/>
			<field name="prioritySelect" showIf="typeSelect == 3" colSpan="6"/>
		</panel>
		
		<panel sidebar="true" title="References" name="meetingLinkedPanel" canCollapse="true">
			<field name="partner" canEdit="false" colSpan="6" onSelect="action-partner-attrs-set-domain" onChange="action-event-group-partner-onchange" form-view="partner-form" grid-view="partner-grid" />
			<field name="contactPartner" canEdit="false" colSpan="6" hideIf="partner.partnerTypeSelect == 2" onChange="action-group-crm-meeting-contactpartner-onchange" onSelect="action-event-attrs-contact-partner-domain" domain="self.isContact = true" form-view="partner-contact-form" grid-view="partner-contact-grid"/>
			<field name="lead" canEdit="false" colSpan="6" onChange="action-meeting-set-location-lead, action-event-method-add-guest" form-view="lead-form" grid-view="lead-grid"/>
			<field name="campaign" canEdit="false" colSpan="6" form-view="campaign-form" grid-view="campaign-grid"/>
			<field name="relatedToSelect" widget="RefSelect" x-related="relatedToSelectId"/>
			<field name="relatedToSelectId" hidden="true" />
			<field name="partner.partnerTypeSelect" hidden="true"/>
		</panel>

		<panel name="attrsPanel">
			<field name="attrs" colSpan="12" />
		</panel>
		
		<panel-mail name="mailPanel">
			<mail-messages/>
			<mail-followers/>
		</panel-mail>
	</form>
	
	<action-group name="action-group-crm-event-onnew">
        <action name="action-icalendar-event-default-record"/>
		<action name="action-event-new-record"/>
		<action name="action-event-record-current-user"/>
	</action-group>

	<action-group name="action-group-crm-event-onload">
		<action name="action-partner-method-check-rights" if="calendar != null"/>
		<action name="action-event-hide-private" if="typeSelect == 2" />
	</action-group>
	
	<action-record name="action-event-record-current-user" model="com.axelor.apps.crm.db.Event">
		<field name="user" expr="eval:__user__"/>
	</action-record>
    
    <action-method name="action-event-method-domain-calendar">
    	<call class="com.axelor.apps.crm.web.EventController" method="setCalendarDomain"/>
    </action-method>
    
    <action-method name="action-partner-method-check-rights">
    	<call class="com.axelor.apps.crm.web.EventController" method="checkRights"/>
    </action-method>
    
    <action-method name="action-event-method-change-creator">
    	<call class="com.axelor.apps.crm.web.EventController" method="changeCreator"/>
    </action-method>

    <action-method name="action-method-crm-event-assign-tome">
    	<call class="com.axelor.apps.crm.web.EventController" method="assignToMeEvent"/>
    </action-method>

    <action-view name="dashlet.meeting" title="Meetings" model="com.axelor.apps.crm.db.Event">
        <view type="grid" name="event-grid" />
        <view type="form" name="event-form" />
        <domain>self.typeSelect = 2</domain>
    </action-view>

    <action-method name="action-event-method-add-email-guest">
    	<call class="com.axelor.apps.base.web.ICalendarEventController" method="addEmailGuest"/>
    </action-method>

    <action-method name="action-event-method-manage-followers">
    	<call class="com.axelor.apps.crm.web.EventController" method="manageFollowers"/>
    </action-method>

    <action-group name="action-group-crm-meeting-contactpartner-onchange">
    	<action name="action-attrs-client-partner"/>
    	<action name="action-meeting-set-location-contact"/>
    	<action name="action-event-method-add-guest"/>
    </action-group>

    <action-group name="action-event-group-partner-onchange">
    	<action name="action-meeting-set-location-partner"/>
    	<action name="action-event-method-add-guest"/>
    </action-group>
    
    <action-attrs name="action-event-hide-private">
    	<attribute name="hidden" for="meetingGeneralPanel" expr="eval: (__user__ != user &amp;&amp; !internalGuestSet?.contains(__user__)) &amp;&amp; visibilitySelect == 2"/>
    	<attribute name="hidden" for="meetingAttributesPanel" expr="eval: (__user__ != user &amp;&amp; !internalGuestSet?.contains(__user__)) &amp;&amp; visibilitySelect == 2"/>
    	<attribute name="hidden" for="meetingGuests" expr="eval: (__user__ != user &amp;&amp; !internalGuestSet?.contains(__user__)) &amp;&amp; visibilitySelect == 2"/>
    	<attribute name="hidden" for="meetingLinkedPanel" expr="eval: (__user__ != user &amp;&amp; !internalGuestSet?.contains(__user__)) &amp;&amp; visibilitySelect == 2"/>
    	<attribute name="hidden" for="panelMail" expr="eval: (__user__ != user &amp;&amp; !internalGuestSet?.contains(__user__)) &amp;&amp; visibilitySelect == 2"/>
    </action-attrs>

    <action-group name="action-group-crm-task-start-click">
    	<action name="action-set-task-status-select-2"/>
    </action-group>
    
    <action-group name="action-group-crm-task-pause-click">
    	<action name="action-set-task-status-select-3"/>
    </action-group>
    
    <action-group name="action-group-crm-task-accept-click">
    	<action name="action-set-task-status-select-4"/>
    </action-group>

	<action-group name="action-event-group-on-save">
		<action name="action-event-record-compute-attendee-list"/>
		<action name="action-event-record-subjectTeam"/>
		<action name="action-event-view-modifications-recurrence" if="recurrenceConfiguration &amp;&amp; id > 0"/>
		<action name="save"/>
		<action name="action-event-method-manage-followers"/>
	</action-group>
	
	<action-view name="action-event-view-modifications-recurrence" title="Apply modifications" model="com.axelor.apps.base.db.Wizard">
		<view type="form" name="modifications-assistant-form"/>
		<view-param name="popup" value="reload"/>
	    <view-param name="forceEdit" value="true"/> 
	    <view-param name="width" value="800" />
	    <view-param name="show-toolbar" value="false" />
	    <view-param name="popup-save" value="false" />
	    <context name="_idEvent" expr="eval: id"/>
	</action-view>
	

	<action-view name="action-event-view-create-opportunity" title="Create opportunity" model="com.axelor.apps.crm.db.Opportunity">
    	<view type="form" name="opportunity-form"/>
    	<context name="_customer" expr="eval: partner"/>
    	<context name="_leadName" expr="eval: lead"/>
    </action-view>

    <action-view name="action-event-view-create-event" title="Create event" model="com.axelor.apps.crm.db.Event">
    	<view type="form" name="event-form"/>
    	<context name="_partner" expr="eval: partner"/>
    	<context name="_contactPartner" expr="eval: contactPartner"/>
    	<context name="_eventLead" expr="eval: lead"/>
    	<context name="_relatedToSelect" expr="eval: relatedToSelect"/>
    	<context name="_calendar" expr="eval: calendar"/>
    	<context name="_typeSelect" expr="eval: typeSelect"/>
    	<context name="_relatedToSelectId" expr="eval: relatedToSelectId"/>
    </action-view>

	<form model="com.axelor.apps.base.db.Wizard" title="Apply modifications" name="modifications-assistant-form">
		<panel name="wizardPanel">
			<button name="applyToThisBtn" title="Apply changes to this event only" onClick="close" colSpan="12"/>
			<button name="applyToAllBtn" title="Apply changes to all recurrence's events" onClick="action-event-method-apply-changes-to-all" colSpan="12"/>
		</panel>
	</form>

    <action-method name="action-event-method-apply-changes-to-all">
    	<call class="com.axelor.apps.crm.web.EventController" method="applyChangesToAll"/>
    </action-method>
    
   
<!--    ACTION GROUP -->
    
    <action-group name="action-event-new-record">
    	<action name="action-event-default-record"/>
    	<action name="action-event-record-default-duration"/>
    	<action name="action-event-method-compute-from-duration" if="endDateTime == null"/>
    	<action name="action-event-method-compute-from-start-date-time" if="endDateTime != null"/>
    	<action name="action-event-default-record-user" if="_lead == null &amp;&amp; _partner == null"/>
    	<action name="action-event-record-event-from-lead" if="_lead != null"/>
    	<action name="action-event-record-event-from-partner" if="_partner != null || _parentPartner != null"/>
    	<action name="action-event-record-task-status-select" if="typeSelect == 3"/>
    	<action name="action-event-record-event-from-sale-order" if="_saleOrder != null" />
    	<action name="action-event-method-add-guest"/>
    	<action name="action-event-record-event-from-opportunity" if="_opportunity != null"/>
    </action-group>

    <action-group name="action-event-type-select-onchange-group">
      <action name="action-event-record-reset-status-select"/>
      <action name="action-event-record-reset-category"/>
    </action-group>

    
<!--     ACTION ATTRIBUTS -->
    
    <action-attrs name="action-event-attrs-watchers-domain">
    	<attribute name="domain" for="userSet" expr="eval: &quot; self.id IN (${project?.memberUserSet?.collect{it.id}.join(',')})&quot;" if="project?.memberUserSet?.collect{it.id}?.size() > 0"/>
    	<attribute name="domain" for="userSet" expr="eval:" if="project?.memberUserSet?.collect{it.id}?.size() == 0"/>
    </action-attrs>
    
    <action-attrs name="action-event-attrs-team-domain">
    	<attribute name="domain" for="team" expr="eval: &quot;self.id IN (${user?.teamSet?.collect{it.id}.join(',')})&quot;" if="user?.teamSet?.collect{it.id}?.size() > 0"/>
    </action-attrs>
    
    <action-attrs name="action-event-attrs-contact-partner-domain">
    	<attribute name="domain" for="contactPartner" expr="eval: &quot;self.isContact = true AND self.id IN (${(partner?.contactPartnerSet != null &amp;&amp; !partner.contactPartnerSet.empty)?partner.contactPartnerSet.collect{it.id}.join(','):'null,null'})&quot;" if="partner"/>
    </action-attrs>

    <action-attrs name="action-attrs-client-partner">
    	<attribute name="value" for="partner" expr="eval: contactPartner?.mainPartner"/>
    </action-attrs>
<!--     ACTION RECORD -->

   	<action-record name="action-event-default-record" model="com.axelor.apps.crm.db.Event">
   		<field name="statusSelect" expr="1"/>
    	<field name="startDateTime" expr="eval: __time__" if="startDateTime == null"/>
      <field name="typeSelect" expr="eval: _typeSelect" if="_typeSelect != null"/>
      <field name="typeSelect" expr="0" if="_typeSelect == null"/>
    	<field name="callTypeSelect" expr="2" if="_typeSelect == '1'"/>
    	<field name="relatedToSelectId" expr="eval:_relatedToSelectId"/>
    	<field name="relatedToSelect" expr="eval:_relatedToSelect"/>
    	<field name="partner" expr="eval: _partner"/>
    	<field name="partner" expr="eval: _contactMainPartner" if="_contactMainPartner"/>
    	<field name="contactPartner" expr="eval: _contactPartner"/>
    	<field name="lead" expr="eval: _parent" if="_parent?._model == 'com.axelor.apps.crm.db.Lead' " />
    	<field name="lead" expr="eval: _eventLead" if="_eventLead != null"/>
    	<field name="relatedToSelect" expr="eval: _relatedToSelect"/>
    	<field name="typeSelect" expr="eval: _typeSelect"/>
    	<field name="relatedToSelectId" expr="eval: _relatedToSelectId"/>
    </action-record>
    
    <action-record name="action-event-record-task-status-select" model="com.axelor.apps.crm.db.Event">
    	<field name="statusSelect" expr="11" />
    	<field name="progressSelect" expr="0"/>
    	<field name="prioritySelect" expr="2" />
    </action-record>

    <action-record name="action-event-record-default-duration" model="com.axelor.apps.crm.db.Event">
      <field name="duration"
        expr="eval: com.axelor.apps.tool.date.DurationTool.computeDuration(startDateTime, endDateTime)"
        if="startDateTime &amp;&amp; endDateTime" />
    </action-record>

    <action-record name="action-event-default-record-user" model="com.axelor.apps.crm.db.Event">
    	<field name="user" expr="eval:__user__" if="typeSelect == 1 || typeSelect == 2 || typeSelect == 3"/>
   		<field name="team" expr="call:com.axelor.apps.base.service.user.UserService:getUserActiveTeam()"/>
    </action-record>

    <action-record name="action-event-record-event-from-lead" model="com.axelor.apps.crm.db.Event">
    	<field name="lead" expr="eval: _lead"/>
    	<field name="user" expr="eval: _lead.user"/>
    	<field name="team" expr="eval: _lead.team"/>
    	<field name="partner" expr="eval: _lead.partner"/>
    </action-record>
    
    <action-record name="action-event-record-event-from-opportunity" model="com.axelor.apps.crm.db.Event">
    	<field name="lead" expr="eval: _opportunity.lead"/>
    	<field name="partner" expr="eval: _opportunity.partner"/>
    	<field if="_opportunity.id != null" name="relatedToSelect" expr="eval:'com.axelor.apps.crm.db.Opportunity'"/>
    	<field name="relatedToSelectId" expr="eval: _opportunity.id"/>
    </action-record>
    
    
    <action-record model="com.axelor.apps.crm.db.Event" name="action-event-record-event-from-sale-order">
	    <field name="partner" expr="eval:_partner?.id != null ? __repo__(Partner).find(_partner.id) : _partner"/>
		<field name="contactPartner" expr="eval:_contactPartner?.id != null ? __repo__(Partner).find(_contactPartner.id) : _contactPartner"/>
	    <field if="_saleOrder.id != null" name="relatedToSelect" expr="eval:'com.axelor.apps.sale.db.SaleOrder'"/>
	    <field name="relatedToSelectId" expr="eval:_saleOrder.id" />
	</action-record>
    
    <action-record name="action-event-record-event-from-partner" model="com.axelor.apps.crm.db.Event">
    	<field name="partner" expr="eval: _partner" if="_partner != null &amp;&amp; _partner.isContact == false &amp;&amp; _partner.isCustomer == true"/>
    	<field name="partner" expr="eval: _partner.mainPartner" if="_partner.isContact == true"/>
    	<field name="partner" expr="eval: _parentPartner" if="_parentPartner != null  &amp;&amp; _partner == null"/>
    	<field name="contactPartner" expr="eval: _partner" if="_partner.isContact == true"/>
    	<field name="description" expr="eval: _partner.description"/>
    	<field name="user" expr="eval: __repo__(User).find(_partner.user.id)" if="_partner.user != null" />
    	<field name="team" expr="eval: _partner.team"/>
    </action-record>
    
    <action-record name="action-meeting-set-location-partner" model="com.axelor.apps.crm.db.Event">
		<field name="location" expr="call:com.axelor.apps.crm.service.EventService:getInvoicingAddressFullName(partner)"/>
	</action-record>

	<action-record name="action-meeting-set-location-contact" model="com.axelor.apps.crm.db.Event">
		<field name="location" expr="eval:contactPartner?.mainAddress?.fullName"/>
	</action-record>

	<action-record name="action-meeting-set-location-lead" model="com.axelor.apps.crm.db.Event">
		<field name="location" expr="eval:(lead?.primaryAddress != null ? lead.primaryAddress+', ' : '')+(lead?.primaryPostalCode != null ? lead.primaryPostalCode+' ' : '')+(lead?.primaryCity != null ? lead.primaryCity: '')"/>
	</action-record>

	<action-record name="action-event-record-compute-attendee-list" model="com.axelor.apps.crm.db.Event">
		<field if="attendees" name="computedAttendeeList" expr="eval:attendees.collect{it?.name}.join(', ')"/>
	</action-record>

	<!-- ACTIONS TO SET SELECTS -->
	
	<action-record name="action-set-task-status-select-2" model="com.axelor.apps.crm.db.Event">
		<field name="statusSelect" expr="eval:12"/>
	</action-record>	
	<action-record name="action-set-task-status-select-3" model="com.axelor.apps.crm.db.Event">
		<field name="statusSelect" expr="eval:13"/>
	</action-record>	
	<action-record name="action-set-task-status-select-4" model="com.axelor.apps.crm.db.Event">
		<field name="statusSelect" expr="eval:14"/>
	</action-record>	

	<action-record name="action-event-new-leave" model="com.axelor.apps.crm.db.Event">
		<field name="typeSelect" expr="4"/>
		<field name="user" expr="eval: __user__"/>
		<field name="startDateTime" expr="eval: __datetime__" if="startDateTime == null"/>
	</action-record>
	
	<action-record name="action-event-record-subjectTeam" model="com.axelor.apps.crm.db.Event">
		<field name="subjectTeam" expr="eval: subject" if="visibilitySelect == 1"/>
		<field name="subjectTeam" expr="eval: com.axelor.i18n.I18n.get('Busy')" if="visibilitySelect == 2 &amp;&amp; disponibilitySelect == 1"/>
		<field name="subjectTeam" expr="eval: com.axelor.i18n.I18n.get('Available')" if="visibilitySelect == 2 &amp;&amp; disponibilitySelect == 2"/>
	</action-record>

    <action-record name="action-event-record-reset-status-select" model="com.axelor.apps.crm.db.Event">
        <field name="statusSelect" expr="eval: 1" if="typeSelect != 3 &amp;&amp; statusSelect &gt; 9"/>
        <field name="statusSelect" expr="eval: 11" if="typeSelect == 3 &amp;&amp; statusSelect &lt;= 9"/>
    </action-record>

    <action-record name="action-event-record-reset-category" model="com.axelor.apps.crm.db.Event">
        <field name="eventCategory" expr="eval: null"/>
    </action-record>
	
<!-- 	ACTION METHOD -->

	<action-method name="action-event-method-compute-from-start-date-time">
    	<call class="com.axelor.apps.crm.web.EventController" method="computeFromStartDateTime"/>
    </action-method>
	
    <action-method name="action-event-method-compute-from-end-date-time">
    	<call class="com.axelor.apps.crm.web.EventController" method="computeFromEndDateTime"/>
    </action-method>
    
    <action-method name="action-event-method-compute-from-duration">
    	<call class="com.axelor.apps.crm.web.EventController" method="computeFromDuration" />
    </action-method>
    
    <action-method name="action-event-method-compute-from-calendar">
    	<call class="com.axelor.apps.crm.web.EventController" method="computeFromCalendar" />
    </action-method>

	<action-method name="action-event-method-generate-recurrence">
		<call class="com.axelor.apps.crm.web.EventController" method="generateRecurrentEvents"/>
	</action-method>

	<action-method name="action-event-method-add-guest">
    	<call class="com.axelor.apps.crm.web.EventController" method="addGuest"/>
    </action-method>

<!-- 	FILTERS -->
	
	<search-filters name="crm-tasks-filters" model="com.axelor.apps.crm.db.Event" title="Tasks filters">
		<filter title="My Tasks">
			<domain>self.user = :__user__</domain>
		</filter>
		<filter title="My Today Tasks">
			<domain>self.user = :__user__ and self.startDateTime &lt;= :_todayDateTime</domain>
		</filter>
		<filter title="My Upcoming Tasks">
			<domain>self.user = :__user__ and self.startDateTime &lt; :_newDate and (self.statusSelect = 11 or self.statusSelect = 12)</domain>
		</filter>
		<filter title="My Team Tasks">
			<domain>self.team = :_myActiveTeam</domain>
		</filter>
	</search-filters>
	
	<search-filters name="meeting-filters" model="com.axelor.apps.crm.db.Event" title="Meeting filters">
		<filter title="My Meetings">
			<domain>self.user = :__user__</domain>
		</filter>
		<filter title="My Upcoming Meetings">
			<domain>self.user = :__user__ and self.startDateTime &lt; :_newDate</domain>
		</filter>
		<filter title="My Team Meetings">
			<domain>self.team = :_myActiveTeam</domain>
		</filter>
	</search-filters>
	
	<search-filters name="call-filters" model="com.axelor.apps.crm.db.Event" title="Call filters">
		<filter title="My Calls">
			<domain>self.user = :__user__</domain>
		</filter>
		<filter title="My Today Calls">
			<domain>self.user = :__user__ and self.startDateTime &lt;= :_todayDateTime</domain>
		</filter>
		<filter title="My Team Calls">
			<domain>self.team = :_myActiveTeam</domain>
		</filter>
	</search-filters>
	
	<search-filters name="event-filters" model="com.axelor.apps.crm.db.Event" title="Event filters">
		<filter title="My upcoming events">
			<domain>self.user = :__user__ AND self.startDateTime &gt;= :_currentDate</domain>
		</filter>
		<filter title="My past events">
			<domain>self.user = :__user__  AND self.startDateTime &lt;= :_currentDate</domain>
		</filter>
		<filter title="All upcoming events">
			<domain>self.startDateTime &gt;= :_currentDate</domain>
		</filter>
		<filter title="All past events">
			<domain>self.startDateTime &lt;= :_currentDate</domain>
		</filter>
	</search-filters>
	
	
</object-views>
