<?xml version="1.0" encoding="UTF-8"?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">

  <module name="stock" package="com.axelor.apps.supplychain.db"/>

  <entity name="SupplyChainConfig" lang="java">
     
    <one-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company"/>
    
  	<boolean name="hasOutSmForStorableProduct" title="Generate out. moves for storable products"/>
  	<boolean name="hasOutSmForNonStorableProduct" title="Generate out. moves for non storable products"/>
  	<boolean name="hasInSmForStorableProduct" title="Generate inc. moves for storable products"/>
  	<boolean name="hasInSmForNonStorableProduct" title="Generate inc. moves for non storable products"/>

    <boolean name="autoAllocateOnReceipt" title="Auto allocate stock on receipt"/>
    <boolean name="autoAllocateOnAllocation" title="Auto allocate stock on other stock moves" help="If true, after allocating quantity for a given stock move we allocate the remaining quantity in others stock moves."/>
    <boolean name="autoRequestReservedQty" title="Auto request reserved qty" help="If true, the requested quantity for reservation will be equal to the quantity of the given sale order line."/>
    <boolean name="autoAllocateOnAvailabilityRequest" title="Auto allocate during an availability request"/>
    
    <integer name="defaultEstimatedDate" title="Default estimated date in stock move from sale order" selection="supplychain.estimated.date.select" default="1"/>
    
    <decimal name="numberOfDays" title="Number of days" min="0" />

    <integer name="defaultEstimatedDateForPurchaseOrder" title="Default estimated date in stock move from purchase order" selection="supplychain.estimated.date.select" default="1" />
    
    <decimal name="numberOfDaysForPurchaseOrder" title="Number of days" min="0" />

    <extra-code><![CDATA[

      // Default estimated Date
      public static final int CURRENT_DATE = 0;
      public static final int EMPTY_DATE = 1;
      public static final int CURRENT_DATE_PLUS_DAYS = 2;

    ]]></extra-code>

    <track>
    	<field name="company" on="UPDATE"/>
    	
    	<field name="hasOutSmForStorableProduct" on="UPDATE"/>
    	<field name="hasOutSmForNonStorableProduct" on="UPDATE"/>
    	<field name="hasInSmForStorableProduct" on="UPDATE"/>
    	<field name="hasInSmForNonStorableProduct" on="UPDATE"/>
    	
    	<field name="autoAllocateOnReceipt" on="UPDATE"/>
    	<field name="autoAllocateOnAllocation" on="UPDATE"/>
    	<field name="autoRequestReservedQty" on="UPDATE"/>
    	<field name="autoAllocateOnAvailabilityRequest" on="UPDATE"/>
    	
    	<field name="defaultEstimatedDate" on="UPDATE"/>
    
    	<field name="numberOfDays" on="UPDATE"/>

    	<field name="defaultEstimatedDateForPurchaseOrder" on="UPDATE"/>
    
    	<field name="numberOfDaysForPurchaseOrder" on="UPDATE"/>
    </track>
    
  </entity>
  
</domain-models>
