<?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="purchase-order-supplier-line-grid" title="suppliers requests" canNew="false" model="com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine">
		<hilite if="stateSelect == 1" color="info" />
		<hilite if="stateSelect == 2" color="primary" />
		<hilite if="stateSelect == 3" color="success" />
		<hilite if="stateSelect == 4" color="warning" />
		<hilite if="stateSelect == 5" color="danger" />
		<field name="supplierPartner" form-view="partner-form" grid-view="partner-grid"/>
		<field name="purchaseOrderLine.product" form-view="product-form" grid-view="product-grid" />
		<field name="availableQty" aggregate="sum"/>
		<field name="purchaseOrderLine.unit" form-view="unit-form" grid-view="unit-grid"/>
		<field name="price"/>
		<field name="estimatedDelivDate"/>
		<field name="stateSelect"/>
	</grid>

	<form name="purchase-order-supplier-line-form" title="Supplier request" model="com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine"
		onNew="action-purchase-order-supplier-line-record-request,action-purchase-order-supplier-line-attrs-new" canNew="false">
		<menubar>
			<menu name="purchaseOrderSupplierLineToolsMenu" title="Tools">
				<item name="writeToSupplierItem" title="Write to the supplier" action="save,action-send-by-email-with-template"/>
			</menu>		
		</menubar>
				
		<panel name="statusPanel" title="Status">
			<field name="stateSelect" showTitle="false" readonly="true" colSpan="12" widget="NavSelect"/>	
		</panel>
	   <panel name="mainPanel" >
    	 <field name="supplierPartner" onSelect="action-purchase-order-supplier-line-method-supplier-partner-domain" form-view="partner-form" grid-view="partner-grid"/>
    	 <field name="availableQty"/>
    	 <field name="purchaseOrderLine.unit" form-view="unit-form" grid-view="unit-grid"/>
    	 <field name="price"/>
    	 <field name="estimatedDelivDate"/>
  	   </panel>
  	   <panel name="purchaseOrderDetailsPanel" title="Purchase order Details" readOnly="true">
  	   	 <field name="purchaseOrderLine"/>
  		 <field name="purchaseOrderLine.product"/>
    	 <field name="purchaseOrderLine.qty" title="Ordered quantity"/>
    	 <field name="purchaseOrderLine.price"/>
    	 <field name="purchaseOrderLine.desiredDelivDate"/>
  	  </panel>
	  <panel name="commentsPanel">
	     <field name="comments" colSpan="12"/>
	  </panel>  
	  <panel sidebar="true" name="actionsPanel" title="Actions">
	    <button name="acceptBtn" title="Accept" showIf="stateSelect == 1 || stateSelect == 2"   onClick="save,action-purchase-order-supplier-line-method-accept,save"/>
	    <button name="notAcceptBtn" title="Not accept" showIf="stateSelect == 1 || stateSelect == 2"   onClick="save,action-purchase-order-supplier-line-record-not-accept,save"/>
	    <button name="cancelBtn" title="Cancel" hideIf="stateSelect == 5"   onClick="save,action-purchase-order-supplier-line-record-cancel,save"/>
	    <button name="requestBtn" title="Request" showIf="stateSelect == 5"   onClick="save,action-purchase-order-supplier-line-record-request,save"/>
	  </panel>
	</form>
	
	<grid name="purchase-order-supplier-line-supplier-grid" title="Suppliers requests" model="com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine">
		<field name="purchaseOrderLine.product" form-view="product-form" grid-view="product-grid"/>
		<field name="purchaseOrderLine.qty"/>
		<field name="purchaseOrderLine.desiredDelivDate"/>
		<field name="availableQty" aggregate="sum"/>
		<field name="purchaseOrderLine.unit" form-view="unit-form" grid-view="unit-grid"/>
		<field name="price"/>
		<field name="estimatedDelivDate"/>
		<field name="comments"/>
		<field name="stateSelect"/>
	</grid>
	
	<form name="purchase-order-supplier-line-supplier-form" title="Supplier request" model="com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine" width="large">
	  <panel name="mainPanel" >
	    <field name="stateSelect" showTitle="false" readonly="true" colSpan="12" widget="NavSelect"/>
	    <field name="purchaseOrderLine.purchaseOrder.purchaseOrderSeq"/>
	    <field name="purchaseOrderLine.product" form-view="product-form" grid-view="product-grid"/>
	    <field name="purchaseOrderLine.qty"/>
	    <field name="purchaseOrderLine.unit" form-view="unit-form" grid-view="unit-grid"/>
	    <field name="availableQty" readonlyIf="stateSelect != 1"/>
	    <field name="purchaseOrderLine.desiredDelivDate"/>
	    <field name="price" readonlyIf="stateSelect != 1"/>
	    <field name="estimatedDelivDate" readonlyIf="stateSelect != 1"/>
	    <button name="submit" title="Submit" showIf="stateSelect == 1" onClick="save,action-purchase-order-supplier-line-record-submit,save"/>
	  </panel>
	  <panel name="commentsPanel">
	    <field name="comments" colSpan="12"/>
	  </panel>  
	</form>	
	
	<action-record name="action-purchase-order-supplier-line-record-request" model="com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine">
		<field name="stateSelect" expr="1"/>
	</action-record>
	
	<action-record name="action-purchase-order-supplier-line-record-submit" model="com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine">
		<field name="stateSelect" expr="2"/>
	</action-record>
	
	<action-record name="action-purchase-order-supplier-line-record-not-accept" model="com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine">
		<field name="stateSelect" expr="4"/>
	</action-record>
	
	<action-record name="action-purchase-order-supplier-line-record-cancel" model="com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine">
		<field name="stateSelect" expr="5"/>
	</action-record>

	<action-method name="action-purchase-order-supplier-line-method-accept">
		<call class="com.axelor.apps.suppliermanagement.web.PurchaseOrderSupplierLineController" method="accept"/>
	</action-method>

	<action-method name="action-purchase-order-supplier-line-method-supplier-partner-domain">
		<call class="com.axelor.apps.suppliermanagement.web.PurchaseOrderSupplierLineController" method="supplierPartnerDomain"/>
	</action-method>

	<action-attrs name="action-purchase-order-supplier-line-attrs-new">
		<attribute name="readonly" for="supplierPartner" expr="eval: false"/>
	</action-attrs>
	
</object-views>
