<?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">
    
	<form name="incl-invoice-payment-partner-form" title="Partner" model="com.axelor.apps.base.db.Partner" onLoad="action-partner-attrs-show-specific-tax-note">
	    <panel name="mainPanel" colSpan="12">
	    	<field name="invoiceSendingFormatSelect" hideIf="isEmployee"/>
	        <field name="invoicesCopySelect" hideIf="!isCustomer || isEmployee"/>
	        <field name="inPaymentMode" canEdit="false" grid-view="payment-mode-grid" form-view="payment-mode-form" domain="self.inOutSelect = 1"/>
	        <field name="outPaymentMode" canEdit="false" grid-view="payment-mode-grid" form-view="payment-mode-form" domain="self.inOutSelect = 2"/>
	        <field name="paymentCondition" canEdit="false" grid-view="payment-condition-grid" form-view="payment-condition-form" hideIf="isEmployee"/>
	        <field name="currency" canEdit="false" requiredIf="!isContact &amp;&amp; partnerTypeSelect != 2" form-view="currency-form" grid-view="currency-grid"/>
	        <field name="fiscalPosition" canEdit="false" form-view="fiscal-position-form" grid-view="fiscal-position-grid" onChange="action-partner-attrs-show-specific-tax-note,action-partner-method-get-default-specific-tax-note"/>
            <field name="specificTaxNote" colSpan="12" hidden="true"/>
	        <field name="analyticDistributionTemplate" canNew="true"/>
	        <panel name="showInvoicesPanel" colSpan="6" hideIf="isEmployee">
	    		<button name="showAllInvoicesBtn" title="Show invoices"  onClick="save,action-partner-view-partner-invoice"/>
        		<button name="showUnpaidInvoiceBtn" title="View all unpaid invoices"  onClick="save,action-partner-view-show-unpaid-invoice"/>
	    	</panel>
	    </panel>
	    <panel name="bankDetailsPanel" title="Bank details" colSpan="12">
	        <field name="bankDetailsList" colSpan="12" showTitle="false" >
                <viewer depends="isDefault,fullName,bankCode,sortCode,accountNbr,bbanKey"><![CDATA[
                    <dl>
                      <dd ng-if="!record.isDefault" ng-style="!record.active && {'color':'orange'}"> {{record.fullName}} </dd>
                      <dd ng-if="record.isDefault" ng-style="!record.active && {'color':'orange'}"> <b>{{record.fullName}}</b> </dd>
                    </dl>
                ]]></viewer>
			    <editor onNew="action-set-default-partner" x-show-on-new="false">
					<field name="ownerName"/>
					<field name="iban" onChange="action-group-account-bankdetails-iban-onchange"/>
					<field name="bank" onChange="action-group-account-bankdetails-iban-onchange" canNew="true"/>
					<field name="bankAddress" showIf="bank" grid-view="bank-address-grid"
						   onSelect="action-attrs-account-bankdetails-bank-set-address-domain"
						   canNew="true" form-view="bank-address-form"/>
					<field name="label"/>
					<field name="isDefault" widget="toggle" x-icon="fa-star-o" x-icon-active="fa-star" x-exclusive="true" />
                    <field name="active" widget="boolean-switch"/>
					<field name="ibanBic" hidden="true" x-bind="{{iban + ' ' + bank.code}}"/>
			    </editor>
			</field>
	    </panel>
	</form>
	
	<form name="incl-customer-balance-partner-form" title="Partner" model="com.axelor.apps.base.db.Partner" >
		<panel name="accountingBalancePanel" title="Accounting balance" colSpan="12">
			<field name="accountingSituationList" colSpan="12" widget="MasterDetail" title="Customer balance" hideIf="isContact"
					grid-view="accounting-situation-partner-grid" form-view="accounting-situation-partner-form"
					onSelect="action-account-accounting-situation-method-update-customer-account"/>
		</panel>
	</form>

    <form name="incl-blocking-partner-form" title="Partner" model="com.axelor.apps.base.db.Partner">
        <panel name="blockingsPanel" title="Blockings" colSpan="12" showIf="isSupplier || isCustomer">
            <field name="blockingList" colSpan="12" title="Blockings" showIf="$readonly()">
				<editor colSpan="12" x-viewer="true" x-show-on-new="false">
					<field name="companySet" colSpan="3" widget="TagSelect"/>
					<field name="blockingSelect" colSpan="2" selection="base.blocking.select"/>
					<field name="blockingToDate" colSpan="2">
						<hilite if="$moment(blockingToDate) &gt; $moment(__date__)" color="danger" strong="true"/>
					</field>
					<field name="blockingReason" colSpan="3" form-view="stop-reason-form" grid-view="stop-reason-grid"/>
					<field name="blockingByUser" colSpan="2" form-view="user-form" grid-view="user-grid"/>
				</editor>
            </field>
            <field name="blockingList" colSpan="12" title="Blockings" showIf="!$readonly()">
                <editor x-show-on-new="false" onNew="action-blocking-record-default-companies,action-blocking-record-realized-by" colSpan="12">
                    <field name="companySet" colSpan="12" widget="TagSelect" onSelect="action-blocking-attrs-domain-companySet" canNew="false"/>
                    <field name="blockingSelect" colSpan="12" selection="base.blocking.select" widget="RadioSelect" required="true"/>
                    <field name="blockingToDate" colSpan="3" required="true"/>
                    <field name="blockingReason" colSpan="3" canNew="true" form-view="stop-reason-form" grid-view="stop-reason-grid"/>
                    <field name="blockingByUser" colSpan="3" readonly="true" form-view="user-form" grid-view="user-grid"/>
                </editor>
            </field>
        </panel>
    </form>

	
	<!-- TODO: find the domain of below form and grid and add it in reportedBalanceList in above form-->

<!-- 	<grid  title="Reported balances" > -->
<!--         <field name="company"/> -->
<!--     </grid> -->
<!--              <form   title="Reported balance" > -->
<!--                  <field name="company" widget="SuggestBox"/> -->
<!--                  <field name="reportedBalanceLineList"  > -->
<!--                      <grid title="Reported balance lines" > -->
<!--                          <field name="year"/> -->
<!--                          <field name="amount"/> -->
<!--                      </grid> -->
<!--                      <form    title="Reported balance line" > -->
<!--                          <field name="year"/> -->
<!--                          <field name="amount"/> -->
<!--                      </form> -->
<!--                  </field> -->
<!--              </form> -->
	
	<form name="incl-sepa-direct-debit-partner-form" title="Partner" model="com.axelor.apps.base.db.Partner">
         <panel name="sepaDirectDebitPanel" title="SEPA Direct Debit" colSpan="12" >
		 	<field name="activeUmr" colSpan="3" canNew="false" domain="self.partner.id = :id"/>
         	<panel-related name="umrListPanel" field="umrList" title="History" colSpan="12"/>
         </panel>
	</form>

	<action-view name="action-partner-view-partner-invoice" title="Invoices" model="com.axelor.apps.account.db.Invoice">
		<view type="grid" name="invoice-grid"/>
		<view type="form" name="invoice-form"/>
		<domain>self.partner.id = :id</domain>
		<context name="id" expr="eval: id"/>
	</action-view>
	
	<action-view name="action-partner-view-show-unpaid-invoice" title="Unpaid invoices" model="com.axelor.apps.account.db.Invoice">
		<view type="grid" name="invoice-grid"/>
		<view type="form" name="invoice-form"/>
		<domain>self.partner.id = :id AND (self.inTaxTotal - self.amountPaid) &gt; 0</domain>
		<context name="id" expr="eval: id"/>
	</action-view>
	
	<action-method name="action-partner-method-show-client-situation" >
		<call class="com.axelor.apps.base.web.PartnerController" method="printClientSituation"/>
	</action-method>
	
	<action-method name="action-partner-method-get-default-specific-tax-note">
		<call class="com.axelor.apps.account.web.PartnerController" method="getDefaultSpecificTaxNote"/>
	</action-method>

	<action-attrs name="action-partner-account-attrs-hide-supplier-account">
		<attribute name="hidden" for="accountingSituationList.supplierAccount" expr="eval: !isSupplier"/>
	</action-attrs>

	<action-attrs name="action-partner-account-attrs-hide-customer-account">
		<attribute name="hidden" for="accountingSituationList.customerAccount" expr="eval: !isCustomer"/>
	</action-attrs>

	<action-attrs name="action-partner-account-attrs-hide-employee-account">
		<attribute name="hidden" for="accountingSituationList.employeeAccount" expr="eval: !isEmployee"/>
	</action-attrs>

    <action-attrs name="action-partner-attrs-show-specific-tax-note">
        <attribute for="specificTaxNote" name="hidden" expr="eval: fiscalPosition == null || !fiscalPosition.customerSpecificNote"/>
    </action-attrs>
    
    <action-view name="action-partner-view-show-customer-debt-recovery" model="com.axelor.apps.account.db.DebtRecovery" title="Debt recovery">
    	<view name="debt-recovery-grid" type="grid"/>
    	<view name="debt-recovery-form" type="form"/>
    	<domain>self.accountingSituation.partner = :_partner</domain>
    	<context name="_partner" expr="eval: __self__"/>
    	<context name="_showSingle" expr="eval:true"/>
    </action-view>
    

	
</object-views>
