<?xml version="1.0" encoding="utf-8"?>
<xml-inputs xmlns="http://axelor.com/xml/ns/data-import"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://axelor.com/xml/ns/data-import http://axelor.com/xml/ns/data-import/data-import_5.2.xsd">
  
  
  <input file="configurator-creator.xml" root="configurator-creators">
  
    <!--  Import configuratorBOMs -->
          
  	<bind node="configurator-boms/configurator-bom" type="com.axelor.apps.production.db.ConfiguratorBOM" update="true" search="self.importId = :importId">
       <bind node="name" to="name"/>
       <bind node="importId" to="importId"/>
       <bind node="companyCode" to="company" search="self.code = :companyCode" if="companyCode">
         <bind node="text()" to="code" alias="companyCode"/>
       </bind>
       <bind node="statusSelect" to="statusSelect"/>
       <bind node="nameFormula" to="nameFormula"/>
       <bind node="defNameAsFormula" to="defNameAsFormula"/>
       <bind node="productCode" to="product" search="self.code = :productCode" if="productCode">
         <bind node="text()" to="code" alias="productCode"/>
       </bind>
       <bind node="productFormula" to="productFormula"/>
       <bind node="defProductAsFormula" to="defProductAsFormula"/>
       <bind node="defProductFromConfigurator" to="defProductFromConfigurator"/>
	   <bind node="qty" to="qty"/>
	   <bind node="qtyFormula" to="qtyFormula"/>
	   <bind node="defQtyAsFormula" to="defQtyAsFormula"/>
	   <bind node="unitId" to="unit" search="self.id = :unitId" if="unitId">
         <bind node="text()" to="id" alias="unitId"/>
       </bind>
       <bind node="unitFormula" to="unitFormula"/>
       <bind node="defUnitAsFormula" to="defUnitAsFormula"/>
       <bind node="prodProcessCode" to="prodProcess" search="self.code = :prodProcessCode" if="prodProcessCode">
         <bind node="text()" to="code" alias="prodProcessCode"/>
       </bind>
       
       <bind node="configuratorProdProcess" to="configuratorProdProcess" update="true" search="self.importId = :importId" if="configProdProcessName">
       	 <bind node="importId" to="importId"/>
         <bind node="statusSelect" to="statusSelect"/>
         <bind node="name" to="name" alias="configProdProcessName"/>
         <bind node="code" to="code"/>
         <bind node="codeFormula" to="codeFormula"/>
         <bind node="defCodeAsFormula" to="defCodeAsFormula"/>
         <bind node="companyCode" to="company" search="self.code = :companyCode" if="companyCode">
           <bind node="text()" to="code" alias="companyCode"/>
         </bind>
         <bind node="stockLocation" to="stockLocation" search="self.id = :stockLocationId" if="stockLocationId">
           <bind node="text()" to="id" alias="stockLocationId"/>
         </bind>
         <bind node="stockLocationFormula" to="stockLocationFormula"/>
         <bind node="defStockLocationAsFormula" to="defStockLocationAsFormula"/>
         <bind node="producedProductStockLocation" to="producedProductStockLocation" search="self.id = :producedProductStockLocationId" if="producedProductStockLocationId">
           <bind node="text()" to="id" alias="producedProductStockLocationId"/>
         </bind>
         <bind node="producedProductStockLocationFormula" to="producedProductStockLocationFormula"/>
         <bind node="defProducedProductStockLocationAsFormula" to="defProducedProductStockLocationAsFormula"/>
         <bind node="workshopStockLocation" to="workshopStockLocation" search="self.id = :workshopStockLocationId" if="workshopStockLocationId">
           <bind node="text()" to="id" alias="workshopStockLocationId"/>
         </bind>
         <bind node="workshopStockLocationFormula" to="workshopStockLocationFormula"/>
         <bind node="defWorkshopStockLocationAsFormula" to="defWorkshopStockLocationAsFormula"/>
         <bind node="configuratorProdProcessLineList/configuratorProdProcessLine" to="configuratorProdProcessLineList">
           <bind node="name" to="name"/>
           <bind node="priority" to="priority"/>
           <bind node="workCenter" to="workCenter" search="self.id = :workCenterId" if="workCenterId">
             <bind node="text()" to="id" alias="workCenterId"/>
           </bind>
           <bind node="stockLocation" to="stockLocation" search="self.id = :stockLocationId" if="stockLocationId">
             <bind node="text()" to="id" alias="stockLocationId"/>
           </bind>
           <bind node="outsourcing" to="outsourcing"/>
           <bind node="description" to="description"/>
           <bind node="minCapacityPerCycle" to="minCapacityPerCycle"/>
           <bind node="minCapacityPerCycleFormula" to="minCapacityPerCycleFormula"/>
           <bind node="defMinCapacityFormula" to="defMinCapacityFormula"/>
           <bind node="maxCapacityPerCycle" to="maxCapacityPerCycle"/>
           <bind node="maxCapacityPerCycleFormula" to="maxCapacityPerCycleFormula"/>
           <bind node="defMaxCapacityFormula" to="defMaxCapacityFormula"/>
           <bind node="durationPerCycle" to="durationPerCycle"/>
           <bind node="durationPerCycleFormula" to="durationPerCycleFormula"/>
           <bind node="defDurationFormula" to="defDurationFormula"/>
         </bind>
       </bind>
         
       <bind node="prodProcessFormula" to="prodProcessFormula"/>
       <bind node="defProdProcessAsFormula" to="defProdProcessAsFormula"/>
       <bind node="defProdProcessAsConfigurator" to="defProdProcessAsConfigurator"/>
       
	   <bind node="parentConfiguratorBOMId" to="parentConfiguratorBOM" update="true" search="self.importId = :parentConfigBOMImportId" create="false">
         <bind node="text()" to="importId" alias="parentConfigBOMImportId"/>
       </bind>
       
       <bind node="useCondition" to="useCondition"/>
       <bind node="billOfMaterialId" to="billOfMaterialId"/>           
       
     </bind>
     
   
   <!--  Import configurator creators  -->
   
     <bind node="configurator-creators/configurator-creator" type="com.axelor.apps.sale.db.ConfiguratorCreator" update="true" search="self.importId = :importId">
     
       <bind node="importId" to="importId"/>
       <bind node="name" to="name"/>
       <bind node="generateProduct" to="generateProduct"/>
       <bind node="isActive" to="isActive"/>
       
       <bind node="attributes/attribute" to="attributes">
         <bind node="name" to="name"/>
         <bind node="title" to="title"/>
         <bind node="type" to="type"/>
         <bind node="defaultValue" to="defaultValue"/>
         <bind node="model" to="model"/>
         <bind node="modelField" to="modelField"/>
         <bind node="selection" to="selection"/>
         <bind node="widget" to="widget"/>
         <bind node="help" to="help"/>
         <bind node="showIf" to="showIf"/>
         <bind node="hideIf" to="hideIf"/>
         <bind node="requiredIf" to="requiredIf"/>
         <bind node="readonlyIf" to="readonlyIf"/>
         <bind node="hidden" to="hidden"/>
         <bind node="required" to="required"/>
         <bind node="nameField" to="nameField"/>
         <bind node="minSize" to="minSize"/>
         <bind node="maxSize" to="maxSize"/>
         <bind node="precision" to="precision"/>
         <bind node="scale" to="scale"/>
         <bind node="regex" to="regex"/>
         <bind node="targetModel" to="targetModel"/>
         <bind node="enumType" to="enumType"/>
         <bind node="formView" to="formView"/>
         <bind node="gridView" to="gridView"/>
         <bind node="domain" to="domain"/>
         <bind node="sequence" to="sequence"/>
         <bind node="onChange" to="onChange"/>
         <bind node="onClick" to="onClick"/>
         <bind node="widgetAttrs" to="widgetAttrs"/>
         <bind node="contextField" to="contextField"/>
         <bind node="contextFieldTarget" to="contextFieldTarget"/>
         <bind node="contextFieldTargetName" to="contextFieldTargetName"/>
         <bind node="contextFieldValue" to="contextFieldValue"/>
       </bind>

       <bind node="configuratorProductFormulaList/configuratorProductFormula" to="configuratorProductFormulaList">
         <bind node="metaField" to="metaField" search="self.name = :metaField and self.metaModel.name = 'Product'" />
         <bind node="formula" to="formula"/>
         <bind node="showOnConfigurator" to="showOnConfigurator"/>
         <bind node="configuratorCreatorImportId" to="productCreator" search="self.importId = :configCreatorImportId" create="false">
         	<bind node="text()" to="importId" alias="configCreatorImportId"/>
         </bind>
       </bind>

       <bind node="configuratorSOLineFormulaList/configuratorSOLineFormula" to="configuratorSOLineFormulaList">
         <bind node="metaField" to="metaField" search="self.name = :metaField and self.metaModel.name = 'SaleOrderLine'"/>
         <bind node="formula" to="formula"/>
         <bind node="showOnConfigurator" to="showOnConfigurator"/>
         <bind node="updateFromSelect" to="updateFromSelect"/>
         <bind node="configuratorCreatorImportId" to="soLineCreator" search="self.importId = :configCreatorImportId" create="false">
           <bind node="text()" to="importId" alias="configCreatorImportId"/>
         </bind>
       </bind>
       
       <bind node="authorizedUserSet/authorizedUser" to="authorizedUserSet" search="self.code = :userCode">
         <bind node="text()" to="code" alias="userCode"/>
       </bind>
       <bind node="authorizedGroupSet/authorizedGroup" to="authorizedGroupSet" search="self.code = :groupCode">
         <bind node="text()" to="code" alias="groupCode"/>
       </bind>
       
<!--        TODO : The link between the configurator creator and its configurator BOM is not created. Check three following lines below. -->
       <bind node="configuratorBomImportId" to="configuratorBom" search="self.importId = :configBomId" create="false">
         <bind node="text()" to="importId" alias="configBomId"/>
       </bind>
       
     </bind>
   
   </input>
   
   
	<!-- TODO : Build arborescence of configuratorBOMs. It's not working for now on. -->

	<!-- <input file="configurator-creator.xml" root="configurator-creators">
		<bind node="configurator-boms/configurator-bom" type="com.axelor.apps.production.db.ConfiguratorBOM" search="self.id = :configBomId" create="false">
			<bind node="id" to="id">
				<bind node="text()" to="id" alias="configBomId" />
			</bind>
			<bind node="parentConfiguratorBOMId" to="parentConfiguratorBOM" search="self.id = :parentConfigBOMId">
				<bind node="text()" to="id" alias="parentConfigBOMId" />
			</bind>
		</bind>
	</input> -->

</xml-inputs>
