<?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="payment-mode-grid" title="Payment Mode" model="com.axelor.apps.account.db.PaymentMode">
        <field name="name"/>
        <field name="code" x-bind="{{code|unaccent|uppercase}}"/>
    </grid>
    
    <form name="payment-mode-form" title="Payment Mode" model="com.axelor.apps.account.db.PaymentMode" onNew="action-payment-mode-set-default" width="large">
        <panel name="mainPanel" >
        	<field name="name"/>
	        <field name="code" x-bind="{{code|unaccent|uppercase}}" />
	        <field name="typeSelect" colSpan="3" onChange="action-payment-mode-group-empty"/>
			<field name="inOutSelect" colSpan="3"/>
  			<field name="validatePaymentByDepositSlipPublication" showIf="inOutSelect == 1 &amp;&amp; [5, 7].indexOf(typeSelect) >= 0" if="__config__.app.getApp('account')?.paymentVouchersOnInvoice" />
		</panel>
		<panel-tabs name="mainPanelTab">
	        <panel-related name="accountManagementListPanel" field="accountManagementList" grid-view="account-management-payment-mode-grid" form-view="account-management-form"
		        domain="self.typeSelect = 3" colSpan="12" if-module="axelor-account" if="__config__.app.isApp('account')" />
	        <panel name="bankOrderPanel" title="Bank order config." if-module="axelor-bank-payment" if="__config__.app.isApp('bank-payment')">
				<field name="generateBankOrder" showIf="typeSelect == 2 || typeSelect == 9" />
				<field name="autoConfirmBankOrder" showIf="generateBankOrder"/>
	  			<field name="automaticTransmission" showIf="generateBankOrder"/>
	  			<field name="generateMoveAutoFromBankOrder" showIf="generateBankOrder"/>
        		<field name="consoBankOrderLinePerPartner" showIf="generateBankOrder"/>
	  			<field name="orderTypeSelect" selection-in="[2,4]" hidden="true" showIf="generateBankOrder &amp;&amp; typeSelect == 2"  requiredIf="generateBankOrder &amp;&amp; typeSelect == 2"/>
	    		<field name="orderTypeSelect" selection-in="[1,3,5,6]" hidden="true" showIf="generateBankOrder &amp;&amp; typeSelect == 9" requiredIf="generateBankOrder &amp;&amp; typeSelect == 9"/>
	  			<field name="bankOrderExportFolderPath" showIf="generateBankOrder" requiredIf="generateBankOrder"/>
	  			<field name="bankOrderFileFormat" domain="self.orderTypeSelect = :orderTypeSelect AND self.fileGenerationSupported = 'true'" canEdit="false" showIf="generateBankOrder" requiredIf="generateBankOrder" form-view="bank-order-file-format-form" grid-view="bank-order-file-format-grid"/>
	        </panel>
		</panel-tabs>
    </form>
    
    <action-group name="action-payment-mode-group-empty" if-module="axelor-bank-payment">
    	<action name="action-payment-mode-record-empty"/>
    </action-group>
    
    <action-record name="action-payment-mode-record-cheque"
    	model="com.axelor.apps.account.db.PaymentMode" 
    	search="('self.typeSelect = ?1', 7)">
    	<field name="typeSelect" expr="7"/>
	</action-record>

	<action-record name="action-payment-mode-set-default" model="com.axelor.apps.account.db.PaymentMode">
	    <field name="accountManagementList" expr="eval:__repo__(Company).all().fetch().collect{__repo__(AccountManagement).create([company:it])}" if="__config__.app.isApp('account')"/>
	</action-record>

</object-views>