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

    <form name="production-config-form" title="Production configuration" model="com.axelor.apps.production.db.ProductionConfig" onNew="action-production-config-record-default">
    	<panel name="mainPanel">
		    <field name="company" canEdit="false" form-view="company-form" colSpan="4" grid-view="company-grid"/>
		</panel>
		<panel name="realizeOrderPanel">
			<field name="stockMoveRealizeOrderSelect"/>
		</panel>
		<panel name="automaticEmailPanel">
			<field name="finishMoAutomaticEmail"/>
			<field name="finishMoMessageTemplate" requiredIf="finishMoAutomaticEmail" showIf="finishMoAutomaticEmail" 
				form-view="template-form" grid-view="template-grid" domain="self.metaModel.name = 'ManufOrder'"/>
			<field name="partFinishMoAutomaticEmail"/>
			<field name="partFinishMoMessageTemplate" requiredIf="partFinishMoAutomaticEmail" showIf="partFinishMoAutomaticEmail" 
				form-view="template-form" grid-view="template-grid" domain="self.metaModel.name = 'ManufOrder'"/>
		</panel>
		<panel name="manufOrderSeqPanel" title="Manufacturing order sequence">
        	<field name="manufOrderSequence" canEdit="true" canNew="true" domain="self.code = 'manufOrder' and self.company = :company"  form-view="sequence-form" grid-view="sequence-grid"/>
			<field name="workshopSequenceConfigLineList" form-view="workshop-sequence-config-line-form" colSpan="12" grid-view="workshop-sequence-config-line-grid"/>
		</panel>
				
		<panel-mail name="mailPanel">
			<mail-messages limit="4"/>
			<mail-followers/>
		</panel-mail>
		
    </form>
	
	<action-record name="action-production-config-record-default" model="com.axelor.apps.production.db.ProductionConfig">
		<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-production-config" title="Production config (${ name })" model="com.axelor.apps.production.db.ProductionConfig">
    	<view type="form" name="production-config-form"/>
    	<context name="_showRecord" expr="eval: __self__.productionConfig?.id"/>
    	<context name="_company" expr="eval: __this__"/>
    </action-view>
    
</object-views>