<?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="prod-residual-product-grid" title="Residual products" model="com.axelor.apps.production.db.ProdResidualProduct" editable="true">
        <field name="product" form-view="product-form" grid-view="product-grid" onChange="action-prod-residual-product-record-product" domain="self.productTypeSelect = 'storable'"/>
        <field name="qty" aggregate="sum" x-scale="2"/>
        <field name="unit" form-view="unit-form" grid-view="unit-grid"/>
    </grid>
    
    <form name="prod-residual-product-form" title="Residual product" model="com.axelor.apps.production.db.ProdResidualProduct"
     onNew="action-prod-residual-product-attrs-qty-digits"
     onLoad="action-prod-residual-product-attrs-qty-digits">
		<panel name="mainPanel">        
	        <field name="product" canEdit="false" form-view="product-form" grid-view="product-grid" onChange="action-prod-residual-product-record-product" domain="self.productTypeSelect = 'storable'"/>
	        <field name="qty"/>
	        <field name="unit" form-view="unit-form" grid-view="unit-grid"/>
        </panel>
    </form>
    
    <action-record name="action-prod-residual-product-record-product" model="com.axelor.apps.production.db.ProdResidualProduct">
    	<field name="unit" expr="eval: product?.unit"/>
    </action-record>
    
    <action-attrs name="action-prod-residual-product-attrs-qty-digits">
    	<attribute name="scale" for="qty" expr="eval: __config__.app.getApp('production').nbDecimalDigitForBomQty"/>
    </action-attrs>
    
</object-views>
