<?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="stock-move-line-sale-order-line-grid" title="Stock move lines" model="com.axelor.apps.stock.db.StockMoveLine" orderBy="stockMove.statusSelect,-stockMove.estimatedDate"
    	canNew="false" canDelete="false">
        <field name="name" width="120"/>	
        <field name="stockMove.realDate"/>
        <field name="realQty" aggregate="sum" onChange="action-stock-move-line-group-real-qty-onchange"/>
        <field name="qtyInvoiced"/>
        <field name="unitPriceUntaxed" x-scale="2"/>
        <field name="unitPriceTaxed" x-scale="2" hidden="true"/>
        <field name="unit" form-view="unit-form" grid-view="unit-grid"/>
        <field name="trackingNumber" form-view="tracking-number-form" grid-view="tracking-number-grid" domain="self.product = :product" readonlyIf="$get('stockMove.statusSelect') > 1"/>
        <field name="stockMove.statusSelect"/>
        <field name="availableStatus" width="150">
        	<hilite strong="true" color="success" if="availableStatusSelect == 1"/>
        	<hilite strong="true" color="info" if="availableStatusSelect == 2"/>
        	<hilite color="danger" strong="true" if="availableStatusSelect == 3"/>
        </field>
    </grid>
    
    <grid name="stock-move-line-produced-manuf-order-grid" title="Stock move lines" model="com.axelor.apps.stock.db.StockMoveLine" orderBy="stockMove.statusSelect,-stockMove.estimatedDate"
      canNew="false" canEdit="false" canDelete="false">
        <field name="producedManufOrder"/>
        <field name="stockMove.stockMoveSeq" /> 
        <field name="stockMove.realDate"/>
        <field name="realQty" aggregate="sum" onChange="action-stock-move-line-group-real-qty-onchange"/>
        <field name="qtyInvoiced"/>
        <field name="unitPriceUntaxed" x-scale="2"/>
        <field name="unitPriceTaxed" x-scale="2" hidden="true"/>
        <field name="unit" form-view="unit-form" grid-view="unit-grid"/>
        <field name="trackingNumber" form-view="tracking-number-form" grid-view="tracking-number-grid" domain="self.product = :product" readonlyIf="$get('stockMove.statusSelect') > 1"/>
        <field name="stockMove.statusSelect"/>
        <field name="availableStatus" width="150">
          <hilite strong="true" color="success" if="availableStatusSelect == 1"/>
          <hilite strong="true" color="info" if="availableStatusSelect == 2"/>
          <hilite color="danger" strong="true" if="availableStatusSelect == 3"/>
        </field>
    </grid>
    
    <grid name="stock-move-line-consumed-manuf-order-grid" title="Stock move lines" model="com.axelor.apps.stock.db.StockMoveLine" orderBy="stockMove.statusSelect,-stockMove.estimatedDate"
      canNew="false" canEdit="false" canDelete="false">
        <field name="consumedManufOrder"/>
        <field name="consumedOperationOrder"/>
        <field name="stockMove.stockMoveSeq" /> 
        <field name="stockMove.realDate"/>
        <field name="realQty" aggregate="sum" onChange="action-stock-move-line-group-real-qty-onchange"/>
        <field name="qtyInvoiced"/>
        <field name="unitPriceUntaxed" x-scale="2"/>
        <field name="unitPriceTaxed" x-scale="2" hidden="true"/>
        <field name="unit" form-view="unit-form" grid-view="unit-grid"/>
        <field name="trackingNumber" form-view="tracking-number-form" grid-view="tracking-number-grid" domain="self.product = :product" readonlyIf="$get('stockMove.statusSelect') > 1"/>
        <field name="stockMove.statusSelect"/>
        <field name="availableStatus" width="150">
          <hilite strong="true" color="success" if="availableStatusSelect == 1"/>
          <hilite strong="true" color="info" if="availableStatusSelect == 2"/>
          <hilite color="danger" strong="true" if="availableStatusSelect == 3"/>
        </field>
    </grid>

    <action-view name="action-stock-move-line-product-reserved-planned" title="${fullName} plan. st. move"
		model="com.axelor.apps.stock.db.StockMoveLine">
		<view type="grid" name="stock-move-line-all-grid-planned"/>
		<view type="form" name="stock-move-line-all-form"/>
		<domain>self.reservedQty > 0 and self.stockMove.statusSelect = 2 and (self.stockMove.fromStockLocation.typeSelect = 1 or self.stockMove.toStockLocation.typeSelect = 1) and self.product.id = :_id</domain>
	</action-view>
	
	<action-view name="action-stock-location-line-view-reserved-stock-move-lines" title="Reserved stock move lines" model="com.axelor.apps.stock.db.StockMoveLine">
    	<view type="grid" name="stock-move-line-all-grid-planned"/>
    	<view type="form" name="stock-move-line-all-form"/>
    	<domain>self.reservedQty > 0 and self.stockMove.statusSelect = 2 AND self.product.id = :productId AND (self.stockMove.fromStockLocation.id = :locationId OR self.stockMove.toStockLocation.id = :locationId)</domain>
    	<context name="productId" expr="eval: product?.id"/>
    	<context name="locationId" expr="eval: stockLocation?.id "/>
    </action-view>

  <action-attrs name="action-supplychain-attrs-stock-order-line-max-reserved-qty">
    <attribute name="value" for="reservedQty" expr="eval: realQty" if="reservedQty > realQty"/>
  </action-attrs>
  
</object-views>	