<?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="crm-config-grid" title="CRM configurations" model="com.axelor.apps.crm.db.CrmConfig">
    <field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
	</grid>

	<form name="crm-config-form" title="CRM configuration" model="com.axelor.apps.crm.db.CrmConfig" onNew="action-crm-config-record-default" width="large">
	  	<panel name="mainPanel" >
	    	<field name="company" canEdit="false" form-view="company-form" colSpan="4" grid-view="company-grid"/>
	  	</panel>
	  	<panel name="reminderTemplatesPanel" title="Reminder Templates">
	  		<field name="eventTemplate" canNew="true" form-view="template-form" grid-view="template-grid"/>
	    	<field name="taskTemplate" canNew="true" form-view="template-form" grid-view="template-grid"/>
	    	<field name="meetingTemplate" canNew="true" form-view="template-form" grid-view="template-grid"/>
	    	<field name="callTemplate" canNew="true" form-view="template-form" grid-view="template-grid"/>
	    	<field name="meetingDateChangeTemplate" canNew="true" form-view="template-form" grid-view="template-grid"/>
	    	<field name="meetingGuestAddedTemplate" canNew="true" form-view="template-form" grid-view="template-grid"/>
	    	<field name="meetingGuestDeletedTemplate" canNew="true" form-view="template-form" grid-view="template-grid"/>
	  	</panel>
	  					        
		<panel-mail name="mailPanel">
			<mail-messages limit="4"/>
			<mail-followers/>
		</panel-mail>
        
	</form>
	
	<action-record name="action-crm-config-record-default" model="com.axelor.apps.crm.db.CrmConfig">
		<field name="company" expr="eval: _company" if="_company != null"/>
		<field name="company"  expr="eval:__user__.activeCompany" if="_company == null &amp;&amp; __user__.activeCompany != null"/>
    	<field name="company"  expr="eval:__repo__(Company).all().fetchOne()" if="_company == null &amp;&amp; __user__.activeCompany == null &amp;&amp; __repo__(Company).all().fetch().size == 1"/>
	</action-record>
	
	<action-view name="action-company-view-crm-config" title="CRM config (${ name })" model="com.axelor.apps.crm.db.CrmConfig">
    	<view type="form" name="crm-config-form"/>
    	<context name="_showRecord" expr="eval: __self__.crmConfig?.id"/>
    	<context name="_company" expr="eval: __this__"/>
    </action-view>
	
</object-views>