<?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="stock-config-grid" title="Stock configurations" model="com.axelor.apps.stock.db.StockConfig">
    <field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
	</grid>

	<form name="stock-config-form" title="Stock configuration" model="com.axelor.apps.stock.db.StockConfig" onNew="action-stock-config-record-default" width="large">
	  <panel name="mainPanel" >
	    <field name="company" canEdit="false" form-view="company-form" colSpan="4" grid-view="company-grid"/>
	  </panel>
	  <panel name="virtualStockLocationsInfoPanel" title="Virtual stock locations informations">
	    <field name="customerVirtualStockLocation" onSelect="action-stock-config-attrs-customer-stocklocation-domain" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid"/>
	    <field name="supplierVirtualStockLocation" onSelect="action-stock-config-attrs-supplier-stocklocation-domain" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid"/>
	    <field name="inventoryVirtualStockLocation" domain="self.typeSelect = 3" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid"/>
		  <field name="productionVirtualStockLocation" domain="self.usableOnProduction = True AND self.typeSelect = 3" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid" if-module="axelor-production" if="__config__.app.isApp('production')"/>
	  </panel>
	  <panel name="stockMoveInfoPanel" title="Stock move informations">
		  <panel colSpan="12" name="subStockMoveInfoPanel">
			  <field name="receiptDefaultStockLocation" onSelect="action-stock-config-attrs-receipt-stocklocation-domain" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid"/>
			  <field name="pickupDefaultStockLocation" onSelect="action-stock-config-attrs-pickup-stocklocation-domain" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid"/>
			  <field name="qualityControlDefaultStockLocation" domain="self.company = :company and self.typeSelect != 3" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid"/>
			  <field name="wasteStockLocation" domain="self.usableOnProduction = True AND self.company = :company and self.typeSelect != 3" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid" if-module="axelor-production" if="__config__.app.isApp('production')"/>
			  <field name="componentDefaultStockLocation" domain="self.usableOnProduction = True AND self.company = :company and self.typeSelect != 3" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid" if-module="axelor-production" if="__config__.app.isApp('production')"/>
			  <field name="finishedProductsDefaultStockLocation" domain="self.usableOnProduction = True AND self.company = :company and self.typeSelect != 3" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid" if-module="axelor-production" if="__config__.app.isApp('production')"/>
			  <field name="directOrderStockLocation" domain="self.directOrderLocation = True and self.typeSelect != 3" colSpan="4" form-view="stock-location-form" grid-view="stock-location-grid" if-module="axelor-supplychain" if="__config__.app.isApp('supplychain')"/>
		 	  <field name="isWithReturnSurplus" widget="boolean-switch" colSpan="4"/>
		 	  <field name="isWithBackorder" widget="boolean-switch" colSpan="4"/>
		  </panel>
	  </panel>
	  <panel name="stockRuleInfoPanel" title="Stock rule information">
	    <field name="stockRuleMessageTemplate"/>
	  </panel>
	  <panel name="stockLocationValuePanel" title="Stock location value">
		<field name="stockValuationTypeSelect" />
	  </panel>
	  <panel name="customsInfoPanel" title="Customs">
	  	<field name="customsMassUnit" domain="self.unitTypeSelect = 1"/>
	  </panel>
      <panel name="logisticalFormsPanel" title="Logistical forms">
        <field name="realizeStockMovesUponParcelPalletCollection" />
      </panel>
      <panel-related name="freightCarrierCustomerAccountNumberListPanel" field="freightCarrierCustomerAccountNumberList" form-view="freight-carrier-customer-account-number-form"
          grid-view="freight-carrier-customer-account-number-grid" editable="true" />
		<panel name="plannedStockMovePanel">
			<field name="plannedStockMoveAutomaticMail"/>
			<field name="plannedStockMoveMessageTemplate"
				requiredIf="plannedStockMoveAutomaticMail"
				showIf="plannedStockMoveAutomaticMail"
				form-view="template-form" grid-view="template-grid"/>
		</panel>
		<panel name="realStockMovePanel">
			<field name="realStockMoveAutomaticMail"/>
			<field name="realStockMoveMessageTemplate"
				requiredIf="realStockMoveAutomaticMail"
				showIf="realStockMoveAutomaticMail"
				form-view="template-form" grid-view="template-grid"/>
		</panel>

		<panel name="logisticalFormPanel">
			<field name="logisticalFormAutomaticEmail"/>
			<field name="logisticalFormMessageTemplate" requiredIf="logisticalFormAutomaticEmail" showIf="logisticalFormAutomaticEmail" grid-view="template-grid" form-view="template-form"/>
		</panel>

		<panel name="conformityCertiPanel" title="Conformity certificate">
			<field name="conformityCertificateTitle"/>
			<field name="conformityCertificateDescription" widget="html"/>
			<field name="signatoryUser"/>
		</panel>
		<panel name="stockMovePrintSettingsPanel" title="Stock move printing settings">
			<field name="displayTrackNbrOnPickingPrinting" widget="boolean-switch"/>
			<field name="displayBarcodeOnPickingPrinting" widget="boolean-switch"/>
			<field name="displayCustomerCodeOnPickingPrinting" widget="boolean-switch"/>
			<field name="displayPartnerSeqOnPrinting" widget="boolean-switch"/>
			<field name="displayLineDetailsOnPrinting" widget="boolean-switch"/>
			<field name="pickingOrderPrintingDetailed" widget="boolean-switch"/>
			<field name="isDisplaySaleValueInPrinting" widget="boolean-switch"/>
			<field name="isDisplayAccountingValueInPrinting" widget="boolean-switch"/>
			<field name="isDisplayAgPriceInPrinting" widget="boolean-switch"></field>
			<field name="displayTrackNbrOnCertificateOfConformityPrinting" widget="boolean-switch"/>
			<field name="displayExtRefOnCertificateOfConformityPrinting" widget="boolean-switch"/>
		</panel>
				
		<panel-mail name="mailPanel">
			<mail-messages limit="4"/>
			<mail-followers/>
		</panel-mail>
	</form>
	
	<action-record name="action-stock-config-record-default" model="com.axelor.apps.stock.db.StockConfig">
		<field name="company" expr="eval: _company" if="_company != null"/>
		<field name="company"  expr="eval:__user__.activeCompany" if="_company == null &amp;&amp; __user__.activeCompany != null"/>
    	<field name="company"  expr="eval:__repo__(Company).all().fetchOne()" if="_company == null &amp;&amp; __user__.activeCompany == null &amp;&amp; __repo__(Company).all().fetch().size == 1"/>
	</action-record>
	
	<action-view name="action-company-view-stock-config" title="Stock config (${ name })" model="com.axelor.apps.stock.db.StockConfig">
    	<view type="form" name="stock-config-form"/>
    	<context name="_showRecord" expr="eval: __self__.stockConfig?.id"/>
    	<context name="_company" expr="eval: __this__"/>
    </action-view>

    <action-attrs name="action-stock-config-attrs-customer-stocklocation-domain" model="com.axelor.apps.stock.db.StockConfig">
        <attribute name="domain" for="customerVirtualStockLocation" expr="eval: &quot; self.typeSelect = 3 &quot;"/>
    </action-attrs>

    <action-attrs name="action-stock-config-attrs-supplier-stocklocation-domain" model="com.axelor.apps.stock.db.StockConfig">
        <attribute name="domain" for="supplierVirtualStockLocation" expr="eval: &quot; self.typeSelect = 3 &quot;"/>
    </action-attrs>

    <action-attrs name="action-stock-config-attrs-receipt-stocklocation-domain" model="com.axelor.apps.stock.db.StockConfig">
        <attribute name="domain" for="receiptDefaultStockLocation" expr="eval: &quot; self.company = :company and self.typeSelect != 3 &quot;"/>
    </action-attrs>

    <action-attrs name="action-stock-config-attrs-pickup-stocklocation-domain" model="com.axelor.apps.stock.db.StockConfig">
        <attribute name="domain" for="pickupDefaultStockLocation" expr="eval: &quot; self.company = :company and self.typeSelect != 3 &quot;"/>
    </action-attrs>
	
</object-views>
