<?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="sale-order-line-project-grid" title="Sale order lines" model="com.axelor.apps.sale.db.SaleOrderLine" orderBy="-saleOrder.orderDate">
        <hilite if="$get('saleOrder.statusSelect') &lt; 3 &amp;&amp; toInvoice &amp;&amp; !invoiced" color="info"/>
        <hilite if="invoiced" color="success"/>
        <field name="project" />
        <field name="saleOrder.saleOrderSeq" width="120" title="Reference"/>
        <field name="saleOrder.creationDate"/>
        <field name="product.code" width="120"/>
        <field name="productName" readonly="true"/>
        <field name="reservedQty" if="__config__.app.getApp('supplychain')?.manageStockReservation" aggregate="sum" readonly="true"/>
        <field name="exTaxTotal" aggregate="sum" readonly="true"/>
        <field name="amountInvoiced" />
        <field name="saleOrder.currency"/>
        <field name="toInvoice"/>
        <button name="updateToInvoiceBtn" title="Update to invoice" readonlyIf="amountInvoiced >= exTaxTotal" icon="fa-check-circle" onClick="action-sale-order-line-method-update-to-invoice" />
        <field name="saleOrder.statusSelect" hidden="true"/>
        <field name="invoiced" hidden="true" />
    </grid>

    <action-method name="action-sale-order-line-method-set-project">
    	<call class="com.axelor.apps.businessproject.web.SaleOrderLineProjectController" method="setProject"/>
    </action-method>
    
    <action-method name="action-sale-order-line-method-unset-project">
    	<call class="com.axelor.apps.businessproject.web.SaleOrderLineProjectController" method="unsetProject"/>
    </action-method>
    
    <action-method name="action-sale-order-line-method-update-to-invoice">
    	<call class="com.axelor.apps.businessproject.web.SaleOrderLineProjectController" method="updateToInvoice"/>
    </action-method>
	
	<action-record name="action-sale-order-line-record-update-to-invoice" model="com.axelor.apps.sale.db.SaleOrderLine">
		<field name="toInvoice" expr="eval:!toInvoice" if="!invoiced"/>
	</action-record>

</object-views>