<?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="account-clearance-grid" title="Account clearance operations" model="com.axelor.apps.account.db.AccountClearance">
		<field name="name" width="120"/>
		<field name="dateTime"/>
		<field name="user" form-view="user-form" grid-view="user-grid"/>
		<field name="amountThreshold"/>
		<field name="dateThreshold"/>
		<field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="statusSelect" />
	</grid>
    
	<form name="account-clearance-form" title="Account clearance" model="com.axelor.apps.account.db.AccountClearance"
	onNew="action-account-clearance-record-default">
		
		<panel name="generalPanel" title="General">
			<field name="name"/>
			<field name="dateTime"/>
			<field name="user" form-view="user-form" grid-view="user-grid" canNew="false" canEdit="false" canView="false"/>
			<field name="company" widget="SuggestBox" form-view="company-form" canEdit="false" grid-view="company-grid"/>
			<field name="statusSelect"/>
		</panel>
		
		<panel name="clearanceSettingsPanel" title="Clearance settings" >
			<field name="amountThreshold"/>
			<field name="dateThreshold"/>
		</panel>
		
		<panel-related name="moveLineSetPanel" field="moveLineSet" form-view="move-line-form" grid-view="move-line-grid"/>  
		
		<panel sidebar="true" name="actionsPanel" title="Actions"> 
			<button name="getExcessPaymentBtn" title="Get overdue payments" onClick="save,action-method-account-clearance-get-excesspayment,save" hideIf="statusSelect == 2" colSpan="12"/>
			<button name="validateAccountClearanceBtn" title="Validate account clearances" onClick="save,action-method-account-clearance-validate,save" hideIf="statusSelect == 2" colSpan="12"/>
			<button name="showAccountClearanceMoveLinesBtn" title="Move lines generated"  onClick="action-method-account-clearance-show-move-lines" showIf="statusSelect == 2" colSpan="12"/> 
		</panel>
	
	</form>
    
    <action-method name="action-method-account-clearance-get-excesspayment">
    	<call class="com.axelor.apps.account.web.AccountClearanceController" method="getExcessPayment"/>
    </action-method>
    
    <action-method name="action-method-account-clearance-validate">
    	<call class="com.axelor.apps.account.web.AccountClearanceController" method="validateAccountClearance"/>
    </action-method>
    
    <action-method name="action-method-account-clearance-show-move-lines">
    	<call class="com.axelor.apps.account.web.AccountClearanceController" method="showAccountClearanceMoveLines"/>
    </action-method>
    
    <action-record name="action-account-clearance-record-default" model="com.axelor.apps.account.db.AccountClearance">
        <field name="user" 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>
    
</object-views>