<?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">

   <form name="product-production-form" title="Product" model="com.axelor.apps.base.db.Product">
       <panel name="mainPanel" colSpan="12">
            <field name="costSheetGroup" showIf="productSubTypeSelect == 3" canEdit="false" form-view="cost-sheet-group-form" grid-view="cost-sheet-group-grid" domain="self.costTypeSelect = 1"/>
            <field name="economicManufOrderQty"/>
           	<field name="defaultBillOfMaterial" canEdit="false" onSelect="action-product-attrs-bill-of-material-domain" form-view="bill-of-material-form" grid-view="bill-of-material-grid"/>
			<field name="lastProductionPrice" readonly="true"/>
		   	<field name="realOrEstimatedPriceSelect" onChange="action-product-group-cost-type-select-onchange"/>
		   	<field name="manufOrderCompValuMethodSelect" showIf="productSubTypeSelect == 1 || productSubTypeSelect == 2"/>
		   	<field name="bomCompValuMethodSelect" showIf="productSubTypeSelect == 1 || productSubTypeSelect == 2"/>
			<button name="createProductionOrderBtn" title="Create production order"  onClick="save,action-product-view-create-production-order"/>
			<panel-dashlet name="showBOMPanel" action="action-product-view-show-bill-of-material" colSpan="12"/>
       </panel>
	</form>    
	
	<action-view name="action-product-view-production-process" title="Production processes"
		model="com.axelor.apps.production.db.ProdProcess">
		<view type="grid" name="prod-process-grid"/>
		<view type="form" name="prod-process-form"/>
		<domain>self.product.id = :id </domain>
	</action-view>	
	
	<action-view name="action-product-view-show-used-bill-of-material" title="Where-used list" 
		model="com.axelor.apps.production.db.BillOfMaterial">
		<view type="grid" name="bill-of-material-grid"/>
		<view type="form" name="bill-of-material-form"/>
		<domain>self.billOfMaterialSet.product.id = :id</domain>
	</action-view>
	
	<action-attrs name="action-product-attrs-bill-of-material-domain">
		<attribute name="domain" for="defaultBillOfMaterial" expr="eval: &quot;(self.product.id = ${parentProduct?.id} OR self.product.id = ${id}) AND self.defineSubBillOfMaterial = true&quot;"/>
	</action-attrs>
	
	<action-attrs name="action-product-attrs-readonly-create-production-order">
		<attribute name="readonly" for="createProductionOrderBtn" expr="eval: __repo__(BillOfMaterial).all().filter('(self.product.id = ?1 OR self.product.id = ?2) AND self.defineSubBillOfMaterial = true', parentProduct?.id, id).fetch().isEmpty()"/>
	</action-attrs>
	
    <action-record name="action-product-record-default-production" model="com.axelor.apps.base.db.Product" if-module="axelor-production">
    	<field name="procurementMethodSelect" expr="produce" if="_fromProduction"/>
    	<field name="costSheetGroup" expr="eval: __config__.app.getApp('production')?.getProductCostSheetGroup()" if="__config__.app.getApp('production')?.getManageCostSheetGroup()" />
    </action-record>
    
    <action-attrs name="action-product-attrs-scale-and-precision-production" if-module="axelor-production">
		<attribute name="scale" for="lastProductionPrice" expr="eval: __config__.app.getNbDecimalDigitForUnitPrice()" />
	</action-attrs>

    <action-method name="action-method-production-building-quantity-product">
		<call class="com.axelor.apps.production.web.ProductionProjectedStockController" method="showBuildingQuantityOfProduct"/>
    </action-method>
   
    <action-method name="action-method-production-consume-product">
		<call class="com.axelor.apps.production.web.ProductionProjectedStockController" method="showConsumeQuantityOfProduct"/>
    </action-method>
  
	<action-method name="action-method-production-missing-product">
		<call class="com.axelor.apps.production.web.ProductionProjectedStockController" method="showMissingQuantityOfProduct"/>
	</action-method>
  
</object-views>
