<?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="direct-debit-management-grid" title="Direct debits management" model="com.axelor.apps.account.db.DirectDebitManagement">
        <field name="debitNumber" width="120"/>
    </grid>
    
    <form name="direct-debit-management-form-payment-schedule-line" title="Direct debits management" model="com.axelor.apps.account.db.DirectDebitManagement"  onNew="action-direct-debit-managemen-set-default" width="large">
        <panel name="mainPanel" >
        	<field name="company" canEdit="false" widget="SuggestBox" form-view="company-form" grid-view="company-grid"/>
        	<field name="debitNumber"/>
        </panel>
        <panel-related name="paymentScheduleLineListPanel" field="paymentScheduleLineList" form-view="payment-schedule-line-form" grid-view="payment-schedule-line-grid"/>
    </form>
    
    <form name="direct-debit-management-form-invoice" title="Direct debit management" model="com.axelor.apps.account.db.DirectDebitManagement"  onNew="action-direct-debit-managemen-set-default" width="large">
        <panel name="mainPanel" >
        	<field name="company" canEdit="false" widget="SuggestBox" form-view="company-form" grid-view="company-grid"/>
        	<field name="debitNumber"/>
        </panel>
        <panel-related name="invoiceSetPanel" field="invoiceSet" grid-view="invoice-grid" form-view="invoice-form"/>
    </form>
    
    <action-record name="action-direct-debit-managemen-set-default" model="com.axelor.apps.account.db.DirectDebitManagement">
        <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>