<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<object-views xmlns="http://axelor.com/xml/ns/object-views"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://axelor.com/xml/ns/object-views http://axelor.com/xml/ns/object-views/object-views_5.2.xsd">
   
    <grid name="product-variant-grid" title="Product variants" model="com.axelor.apps.base.db.ProductVariant">
        <field name="productVariantAttr1" grid-view="product-variant-attr-grid" form-view="product-variant-attr-form"/>
        <field name="productVariantAttr2" grid-view="product-variant-attr-grid" form-view="product-variant-attr-form"/>
        <field name="productVariantAttr3" grid-view="product-variant-attr-grid" form-view="product-variant-attr-form"/>
        <field name="productVariantAttr4" grid-view="product-variant-attr-grid" form-view="product-variant-attr-form"/>
        <field name="productVariantValue1" form-view="product-variant-value-form" grid-view="product-variant-value-grid"/>
        <field name="productVariantValue2" form-view="product-variant-value-form" grid-view="product-variant-value-grid"/>
        <field name="productVariantValue3" form-view="product-variant-value-form" grid-view="product-variant-value-grid"/>
        <field name="productVariantValue4" form-view="product-variant-value-form" grid-view="product-variant-value-grid"/>
    </grid>
    
    <form name="product-variant-form" title="Product variant" model="com.axelor.apps.base.db.ProductVariant"
    	onLoad="action-product-variant-attrs-domain" onNew="action-product-variant-record-on-new" width="large">
    	<panel name="mainPanel" >
        	<field name="productVariantAttr1" showTitle="false" readonly="true" grid-view="product-variant-attr-grid" form-view="product-variant-attr-form"/>
        	<field name="productVariantValue1" showTitle="false" widget="SuggestBox" showIf="productVariantAttr1" form-view="product-variant-value-form" grid-view="product-variant-value-grid"/>
	        <field name="productVariantAttr2" showTitle="false" readonly="true" showIf="productVariantAttr1" grid-view="product-variant-attr-grid" form-view="product-variant-attr-form"/>
        	<field name="productVariantValue2" showTitle="false" widget="SuggestBox" showIf="productVariantAttr2" form-view="product-variant-value-form" grid-view="product-variant-value-grid"/>
	        <field name="productVariantAttr3" showTitle="false" readonly="true" showIf="productVariantAttr2" grid-view="product-variant-attr-grid" form-view="product-variant-attr-form"/>
    	    <field name="productVariantValue3" showTitle="false" widget="SuggestBox" showIf="productVariantAttr3" form-view="product-variant-value-form" grid-view="product-variant-value-grid"/>
	        <field name="productVariantAttr4" showTitle="false" readonly="true" showIf="productVariantAttr3" grid-view="product-variant-attr-grid" form-view="product-variant-attr-form"/>
    	    <field name="productVariantValue4" showTitle="false" widget="SuggestBox" showIf="productVariantAttr4" form-view="product-variant-value-form" grid-view="product-variant-value-grid"/>
        </panel>
    </form>
    
    <!-- ACTION ATTRS -->
    
    <action-attrs name="action-product-variant-attrs-domain">
    	<attribute name="domain" for="productVariantValue1" expr="eval: (_parent?.parentProduct?.productVariantConfig?.productVariantValue1Set?.collect{it.id}?.size() &gt; 0) ? &quot;self.id IN (${_parent?.parentProduct?.productVariantConfig?.productVariantValue1Set?.collect{it.id}?.join(',')})&quot; : &quot;self.id IN (null)&quot;"/>
    	<attribute name="domain" for="productVariantValue2" expr="eval: (_parent?.parentProduct?.productVariantConfig?.productVariantValue2Set?.collect{it.id}?.size() &gt; 0) ? &quot;self.id IN (${_parent?.parentProduct?.productVariantConfig?.productVariantValue2Set?.collect{it.id}?.join(',')})&quot; : &quot;self.id IN (null)&quot;"/>
    	<attribute name="domain" for="productVariantValue3" expr="eval: (_parent?.parentProduct?.productVariantConfig?.productVariantValue3Set?.collect{it.id}?.size() &gt; 0) ? &quot;self.id IN (${_parent?.parentProduct?.productVariantConfig?.productVariantValue3Set?.collect{it.id}?.join(',')})&quot; : &quot;self.id IN (null)&quot;"/>
    	<attribute name="domain" for="productVariantValue4" expr="eval: (_parent?.parentProduct?.productVariantConfig?.productVariantValue4Set?.collect{it.id}?.size() &gt; 0) ? &quot;self.id IN (${_parent?.parentProduct?.productVariantConfig?.productVariantValue4Set?.collect{it.id}?.join(',')})&quot; : &quot;self.id IN (null)&quot;"/>
    </action-attrs>
    
    
    <!-- ACTION RECORD -->
    
    <action-record name="action-product-variant-record-on-new" model="com.axelor.apps.base.db.ProductVariant">
    	<field name="productVariantAttr1" expr="eval: _parent?.parentProduct?.productVariantConfig?.productVariantAttr1"/>
    	<field name="productVariantAttr2" expr="eval: _parent?.parentProduct?.productVariantConfig?.productVariantAttr2"/>
    	<field name="productVariantAttr3" expr="eval: _parent?.parentProduct?.productVariantConfig?.productVariantAttr3"/>
    	<field name="productVariantAttr4" expr="eval: _parent?.parentProduct?.productVariantConfig?.productVariantAttr4"/>
    </action-record>

</object-views>