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

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

	<many-to-one name="productVariantAttr1" ref="com.axelor.apps.base.db.ProductVariantAttr"/>
	<many-to-one name="productVariantAttr2" ref="com.axelor.apps.base.db.ProductVariantAttr"/>
	<many-to-one name="productVariantAttr3" ref="com.axelor.apps.base.db.ProductVariantAttr"/>
	<many-to-one name="productVariantAttr4" ref="com.axelor.apps.base.db.ProductVariantAttr"/>
	<many-to-one name="productVariantValue1" ref="com.axelor.apps.base.db.ProductVariantValue"/>
	<many-to-one name="productVariantValue2" ref="com.axelor.apps.base.db.ProductVariantValue"/>
	<many-to-one name="productVariantValue3" ref="com.axelor.apps.base.db.ProductVariantValue"/>
	<many-to-one name="productVariantValue4" ref="com.axelor.apps.base.db.ProductVariantValue"/>
	
	<boolean name="usedForStock" title="Use for stock only"/>
	
	<string name="name" title="Name" required="true">
		<![CDATA[
		String name = "";
		if(productVariantAttr1 != null && productVariantValue1 != null)  {  name += productVariantAttr1.getName()+" : "+productVariantValue1.getName();  }
		if(productVariantAttr2 != null && productVariantValue2 != null)  { 
			if(!name.equals(""))  {  name += ", ";  }
		 	name += productVariantAttr2.getName()+" : "+productVariantValue2.getName();
		}
		if(productVariantAttr3 != null && productVariantValue3 != null)  { 
			if(!name.equals(""))  {  name += ", ";  }
		 	name += productVariantAttr3.getName()+" : "+productVariantValue3.getName();
		}
		if(productVariantAttr4 != null && productVariantValue4 != null)  { 
			if(!name.equals(""))  {  name += ", ";  }
		 	name += productVariantAttr4.getName()+" : "+productVariantValue4.getName();
		}
		return name;
	    ]]>
	
	</string>
	
  </entity>

</domain-models>
