<?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="ProductionOrder" lang="java">

  	<integer name="prioritySelect" title="Priority" selection="production.order.priority.select" default="2"/>
  	<string name="productionOrderSeq" title="Name" namecolumn="true" initParam="true" required="true" unique="true"/>
  	
 	<many-to-one name="clientPartner" ref="com.axelor.apps.base.db.Partner" title="Customer" />
	<many-to-one name="saleOrder" ref="com.axelor.apps.sale.db.SaleOrder" title="Sale order" />
  	
    <one-to-many name="manufOrderList" ref="com.axelor.apps.production.db.ManufOrder" mappedBy="productionOrder" title="Manufacturing orders" orderBy="prioritySelect"/>
    
    <boolean name="isClosed" >
	    <![CDATA[
	    if(manufOrderList == null || manufOrderList.isEmpty())
	      	return false;
	   	for(ManufOrder mf : manufOrderList){
	   		if(mf.getStatusSelect() != 2 && mf.getStatusSelect() != 6 )
	   		   return false;
	    }    
    	return true;
	    ]]>
    </boolean>
    
    
  </entity>
</domain-models>
