<?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="mail-batch-grid" title="Mail batches" model="com.axelor.apps.base.db.MailBatch">
		<field name="actionSelect" />
		<field name="code" x-bind="{{code|unaccent|uppercase}}" />
		<field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="createdOn"/>
		<field name="createdBy" form-view="user-form" grid-view="user-grid"/>
	</grid>
 
	<form  onNew="action-mail-batch-record-on-new" name="mail-batch-form" title="Mail Batch" model="com.axelor.apps.base.db.MailBatch">
		<panel name="mainPanel" >
			<field name="actionSelect"/>
			<field name="code" x-bind="{{code|unaccent|uppercase}}" onChange="action-base-batch-condition-check-unique-code"/>
			<field name="company" widget="SuggestBox" form-view="company-form" grid-view="company-grid"/>
			<field name="template" widget="SuggestBox" form-view="template-form" grid-view="template-grid"/>
			<field name="archived" title="Archived"/>
		</panel>
		<panel-tabs name="mainPanelTab">
			<panel name="informationPanel" title="Information"  >
				<field name="createdOn" title="Created on"/>
				<field name="createdBy" title="Created by" form-view="user-form" grid-view="user-grid"/>
				<field name="description" showTitle="false"  />
		      	<panel-related name="batchListPanel" field="batchList" colSpan="12" form-view="batch-form" grid-view="batch-grid" readonly="true"/>
			</panel>
			<panel name="emailPagePanel" title="Email Page" hideIf="template != null &amp;&amp; actionSelect == 1">
				<field name="subject" colSpan="12"/>
				<field name="content" widget="html" colSpan="12"/>
			</panel>
		</panel-tabs>
		<panel sidebar="true" name="actionsPanel" title="Actions">
		    <button name="timesheetRemindBatchBtn" title="Remind Timesheet Validation Batch" showIf="actionSelect == 1"  onClick="save,action-mail-batch-method-action-remind-timesheet" colSpan="12"/>
		</panel>
	</form>

    
    <!-- ACTION RECORD -->
    <action-record name="action-mail-batch-record-on-new" model="com.axelor.apps.base.db.MailBatch">
		<field name="createdOn" expr="eval:__config__.app.getTodayDate()"/>
		<field name="createdBy" expr="eval:__user__"/>
		<field name="company"  expr="eval:__user__.activeCompany" if="__user__.activeCompany != null"/>
    	<field name="company"  expr="eval:__repo__(Company).all().fetchOne()" if="__user__.activeCompany == null &amp;&amp; __repo__(Company).all().fetch().size == 1"/>
	</action-record>
    
    
    <!-- ACTION METHOD -->
	<action-method name="action-mail-batch-method-action-remind-timesheet">
		<call class="com.axelor.apps.base.web.MailBatchController" method="remindTimesheet"/>
	</action-method>
	
	
</object-views>