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

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

  	<integer name="priority" title="Priority" initParam="true"/>
<!--     Ajouter action-record pour concatener seq + priority -->
    <string name="name" title="Name" initParam="true"/> 
    
    <string name="operationName" title="Operation name" initParam="true"/>
  
  	<many-to-one name="manufOrder" ref="com.axelor.apps.production.db.ManufOrder" title="Manufacturing order" initParam="true"/>
  
    <many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product" />
  	<decimal name="qty" title="Quantity"/>
    <many-to-one name="unit" ref="com.axelor.apps.base.db.Unit" title="mass" />
  
  	<many-to-one name="workCenter" ref="com.axelor.apps.production.db.WorkCenter" title="Work center" initParam="true"/>
  	<many-to-one name="machineWorkCenter" ref="com.axelor.apps.production.db.WorkCenter" title="Machine" initParam="true"/>
  
  	<one-to-many name="prodHumanResourceList" ref="com.axelor.apps.production.db.ProdHumanResource" mappedBy="operationOrder" title="Human resources"/>
  
  	<one-to-many name="toConsumeProdProductList" ref="com.axelor.apps.production.db.ProdProduct" mappedBy="toConsumeOperationOrder" title="Products to consume"/>
  	<one-to-many name="consumedStockMoveLineList" ref="com.axelor.apps.stock.db.StockMoveLine" mappedBy="consumedOperationOrder" title="Consumed products" orphanRemoval="false"/>
  	<one-to-many name="diffConsumeProdProductList" ref="com.axelor.apps.production.db.ProdProduct" mappedBy="diffConsumeOperationOrder" title="Differences"/>
  
    <integer name="statusSelect" title="Status" selection="production.manuf.order.status.select" initParam="true"/>
    
    <many-to-one name="prodProcessLine" ref="com.axelor.apps.production.db.ProdProcessLine" title="Operation" initParam="true"/> 

      <datetime name="plannedStartDateT" title="Planned start"/>
      <datetime name="plannedEndDateT" title="Planned end"/>

      <datetime name="realStartDateT" title="Real start"/>
      <datetime name="realEndDateT" title="Real end"/>
    
    <one-to-many name="inStockMoveList" ref="com.axelor.apps.stock.db.StockMove" title="Stock move in" mappedBy="inOperationOrder"/>
    
    <long name="plannedDuration" title="Planned duration (hh:mm:ss)"/>
    <long name="realDuration" title="Real duration (hh:mm:ss)"/>
    
    <boolean name="isWithDifference" >
	    <![CDATA[
	    if(diffConsumeProdProductList == null || diffConsumeProdProductList.isEmpty())
	      	return false;
    	return true;
	    ]]>
    </boolean>
    
    <one-to-many name="operationOrderDurationList" ref="com.axelor.apps.production.db.OperationOrderDuration" title="Operation Order Durations" mappedBy="operationOrder"/>

    <string name="comments" title="Comments" large="true"/>
    
    <many-to-one name="barCode" ref="com.axelor.meta.db.MetaFile" title="Barcode" readonly="true"/>

    <integer name="orderByState"/>

	<extra-code><![CDATA[
		// STATUS SELECT
        public static final int STATUS_DRAFT = 1;
        public static final int STATUS_CANCELED = 2;
        public static final int STATUS_PLANNED = 3;
        public static final int STATUS_IN_PROGRESS = 4;
        public static final int STATUS_STANDBY = 5;
        public static final int STATUS_FINISHED = 6;
    ]]></extra-code>

  </entity>
</domain-models>
