<?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.stock.db"/>

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

	  <string name="stockProductionRequestSeq" namecolumn="true" title="Ref." readonly="true"/>
    <string name="name" title="Name"/>
    <integer name="statusSelect" title="Status" selection="stock.production.request.status.select" required="true" readonly="true" default="1"/>
    <integer name="typeSelect" title="Type Status" required="true" selection="stock.production.request.type.select"/>
    <many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company" required="true"/>
    <many-to-one name="partner" ref="com.axelor.apps.base.db.Partner" title="Partner"/>
    <one-to-many name="stockProductionRequestLineList" ref="com.axelor.apps.stock.db.StockProductionRequestLine" mappedBy="stockProductionRequest" orderBy="sequence" title="StockProduction RequestLine content"/>
    <decimal name="exTaxTotal" title="Total W.T." precision="20" scale="2"/>
    <many-to-one name="cancelReason" title="Cancel reason" ref="com.axelor.apps.base.db.CancelReason"/>
    <string name="cancelReasonStr" large="true" title="Cancel Reason str"/>
    <string name="note" title="Notes" large="true"/>
    <many-to-one name="printingSettings" ref="com.axelor.apps.base.db.PrintingSettings"/>
    <many-to-one name="stocklocation" ref="com.axelor.apps.stock.db.StockLocation" required="true" title="Stock location"/>
    <datetime name="realDate" title="Real date" />
    <string name="trackingNumber" title="Tracking number" />
    <!-- final product -->
    <many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product"/>
    <many-to-one name="familleProduit" ref="com.axelor.apps.base.db.FamilleProduit" title="Famille produit"/>
    <datetime name="estimatedDate" title="Estimated date" />
    
    
    <unique-constraint columns="stockProductionRequestSeq,company"/>

    <extra-code><![CDATA[
	
	   	// STATUS SELECT
		public static final int STATUS_DRAFT = 1;
		public static final int STATUS_PLANNED = 2;
		public static final int STATUS_REALIZED = 3;
		public static final int STATUS_CANCELED = 4;
		

      // TYPE SELECT
		public static final int TYPE_SELECT_ORDER = 1;
		public static final int TYPE_SELECT_RETURN = 2;
		
	]]></extra-code>

  <track>
    <field name="statusSelect" />
    <message if="true" on="CREATE">Move created</message>
    <message if="statusSelect == 1" tag="important">Draft move</message>
    <message if="statusSelect == 2" tag="info">Planned move</message>
    <message if="statusSelect == 3" tag="success">Request realized</message>
    <message if="statusSelect == 4" tag="warning">Request canceled</message>
  </track>

	</entity>
</domain-models>
