<?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="journal-grid" title="Journal" model="com.axelor.apps.account.db.Journal">
        <field name="name"/>
		<field name="code" x-bind="{{code|unaccent|uppercase}}"/>
        <field name="journalType"/>
        <field name="exportCode"/>
        <field name="notExportOk"/>
        <field name="statusSelect"/>
        <field name="company" form-view="company-form" grid-view="company-grid"/>
    </grid>
    
	<form name="journal-form" title="Journal" model="com.axelor.apps.account.db.Journal"   
		onNew="account-journal-record-default" width="large">
		<panel name="statusPanel" title="Status">
			<field name="statusSelect" showTitle="false" readonly="true" widget="NavSelect" colSpan="9"/>
			<button name="activeStatusBtn" title="Active" hideIf="statusSelect == 1" onClick="account-journal-record-status-active,save" colSpan="2"/>
		</panel>
		<panel name="mainPanel" >
			<field name="name"/>
			<field name="code" x-bind="{{code|unaccent|uppercase}}" />
			<field name="company" canEdit="false" readonlyIf="statusSelect == 1 || statusSelect == 2" form-view="company-form" grid-view="company-grid"/>
			<field name="journalType" grid-view="journal-type-grid" form-view="journal-type-form"/>
		</panel>
		
		<panel-tabs name="mainPanelTab">
		
			<panel-dashlet name="viewMoveLinePanel" title="General" action="action-journal-view-move-line" height="450" canSearch="true" hideIf="$popup()"/>
		
			<panel name="configurationsPanel" title="Configurations" hideIf="$popup()">
				<panel name="moveLinePanel" title="MoveLine" colSpan="12">
					<field name="sequence" domain="self.code = 'move' and self.company = :company" form-view="sequence-form" grid-view="sequence-grid" canEdit="true" canNew="true"/>
					<field name="isInvoiceMoveConsolidated" widget="Boolean-switch"/>
					<field name="descriptionModel"/>
					<field name="descriptionIdentificationOk"/>
				</panel>  
				<spacer name="moveLineSpacer"/>
				<panel name="paymentsPanel" title="Payments" colSpan="12">
					<field name="editReceiptOk" colSpan="6"/>
					<field name="excessPaymentOk" colSpan="6"/>
				</panel>
				<panel name="moveLinesSecuritySettingsPanel" title="Move lines security settings" colSpan="12">
					<field name="validAccountTypeSet" canNew="false" colSpan="6" form-view="account-type-form" grid-view="account-type-grid"/>
					<field name="validAccountSet" domain="self.company = :company" canNew="false" grid-view="account-simple-grid" colSpan="6" form-view="account-form"/>
				</panel>
				<spacer name="securitySettingsSpacer"/>
				<panel name="exportsPanel" title="Exports" colSpan="12">
					<field name="exportCode" readonlyIf="notExportOk"/>
					<field name="notExportOk" onChange="account-journal-on-change-not-export-ok"/>
				</panel>
				<field name="compatiblePartnerTypeSelect" widget="MultiSelect"/>
			</panel>

		</panel-tabs>

	</form>
    
    <action-view name="action-journal-view-move-line" title="Move lines" model="com.axelor.apps.account.db.MoveLine">
    	<view type="grid" name="move-line-journal-grid"/>
    	<view type="form" name="move-line-form"/>
    	<domain>self.move.journal.id = :id and self.move.ignoreInAccountingOk IN ('false', null) and self.move.period.year.fromDate &lt; :todayDate and self.move.period.year.toDate &gt; :todayDate </domain>	
    	<context name="todayDate" expr="eval:__config__.app.getTodayDate()" />
    </action-view>
    
    
    <action-record name="account-journal-record-default" model="com.axelor.apps.account.db.Journal">
        <field name="statusSelect" expr="eval: 0"/>
        <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-record name="account-journal-record-status-active" model="com.axelor.apps.account.db.Journal">
        <field name="statusSelect" expr="eval: 1"/>
    </action-record>

    <action-record name="account-journal-on-change-not-export-ok" model="com.axelor.apps.account.db.Journal">
    	<field name="exportCode" expr="eval:null" if="notExportOk"/>
    </action-record>

</object-views>