<?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="sale" package="com.axelor.apps.sale.db"/>

    <entity name="SaleOrder" lang="java">

        <many-to-one name="paymentMode" ref="com.axelor.apps.account.db.PaymentMode" title="Payment mode"/>
        <many-to-one name="paymentCondition" ref="com.axelor.apps.account.db.PaymentCondition" title="Payment condition"/>

	    <integer name="deliveryState" title="Delivery State" selection="sale.order.delivery.state" readonly="true" default="1"/>

        <many-to-one name="stockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Stock location"/>
        <date name="shipmentDate" title="Date of shipment" />
        <decimal name="amountInvoiced" title="Amount invoiced W.T." readonly="true"/>
        <integer name="saleOrderTypeSelect" title="Type" required="true" default="1" selection="supplychain.sale.order.type.select"/>
        <!-- Onglet échéancier -->
        <one-to-many name="saleOrderScheduleLineList" ref="com.axelor.apps.sale.db.SaleOrderScheduleLine" mappedBy="saleOrder" title="Schedule line list"/>
        <one-to-many name="timetableList" ref="com.axelor.apps.supplychain.db.Timetable" title="Timetable" mappedBy="saleOrder" copy="false"/>
        <boolean name="interco" title="Interco"/>
        <boolean name="createdByInterco" default="false"/>
        <date name="expectedRealisationDate" title="Expected realisation date" copy="false"/>
        <date name="computationDate" title="Timetable computation date" copy="false"/>
        <many-to-one name="timetableTemplate" title="Timetable template" ref="com.axelor.apps.supplychain.db.TimetableTemplate" copy="false"/>
        <integer name="standardDelay" title="Standard delay (days)" default="0"  />
        <one-to-many name="stockMoveList" ref="com.axelor.apps.stock.db.StockMove" title="Stock moves" />

		<many-to-one name="shipmentMode" ref="com.axelor.apps.stock.db.ShipmentMode"/>
	    <many-to-one name="freightCarrierMode" ref="com.axelor.apps.stock.db.FreightCarrierMode"/>
	    <many-to-one name="carrierPartner" ref="com.axelor.apps.base.db.Partner" title="Carrier" />
	   	<many-to-one name="forwarderPartner" ref="com.axelor.apps.base.db.Partner" title="Forwarder" />
		<many-to-one name="incoterm" ref="com.axelor.apps.stock.db.Incoterm" />

      <boolean name="isNeedingConformityCertificate" title="Is certificate of conformity required"/>
      <boolean name="isIspmRequired" title="Is ISPM 15 required"/>

        <boolean name="directOrderLocation" title="Direct order"/>
        <extra-code>
            <![CDATA[
                // INVOICE
                public static final int INVOICE_ALL = 1;
                public static final int INVOICE_LINES = 2;
                public static final int INVOICE_ADVANCE_PAYMENT = 3;
                public static final int INVOICE_TIMETABLES = 4;

                // SALE ORDER TYPE
                public static final int SALE_ORDER_TYPE_NORMAL = 1;
                public static final int SALE_ORDER_TYPE_SUBSCRIPTION = 2;
                
                // DELIVERY STATE SELECT
                public static final int DELIVERY_STATE_NOT_DELIVERED = 1;
   				public static final int DELIVERY_STATE_PARTIALLY_DELIVERED = 2;
   				public static final int DELIVERY_STATE_DELIVERED = 3;
            ]]>
        </extra-code>
	
    </entity>

</domain-models>
