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

    <form name="purchase-config-form" title="Purchase configuration" model="com.axelor.apps.purchase.db.PurchaseConfig" onNew="action-purchase-config-record-default">
		<panel name="mainPanel" >
		  <field name="company" canEdit="false" form-view="company-form" colSpan="4" grid-view="company-grid"/>
		  <field name="purchaseOrderInAtiSelect"/>
		</panel>
		<panel name="printingSettingsPanel" title="Printing settings">
			<field name="displayBuyerOnPrinting" widget="boolean-switch"/>
			<field name="displayProductCodeOnPrinting" widget="boolean-switch"/>
			<field name="displayTaxDetailOnPrinting" widget="boolean-switch"/>
			<field name="displayProductDetailOnPrinting" widget="boolean-switch"/>
			<field name="displaySupplierCodeOnPrinting" widget="boolean-switch"/>
			<field name="purchaseOrderSupplierBox" widget="html" colSpan="12"/>
			<field name="displayPriceOnQuotationRequest" widget="boolean-switch"/>
		  	<field name="priceRequest" colSpan="12"/>
		</panel>
    <panel name="analyticDistributionPanel" title="Analytic distribution">
      <field name="isAnalyticDistributionRequired" widget="boolean-switch" if="__config__.app.getApp('account')"/>
    </panel>

		<panel-mail name="mailPanel">
			<mail-messages limit="4"/>
			<mail-followers/>
		</panel-mail>
    </form>
    
	<action-record name="action-purchase-config-record-default" model="com.axelor.apps.purchase.db.PurchaseConfig">
		<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-purchase-config" title="Purchase config (${ name })" model="com.axelor.apps.purchase.db.PurchaseConfig">
    	<view type="form" name="purchase-config-form"/>
    	<context name="_showRecord" expr="eval: __self__.purchaseConfig?.id"/>
    	<context name="_company" expr="eval: __this__"/>
    </action-view>
	
</object-views>
