<?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="invoice-line-grid" title="Invoice lines" model="com.axelor.apps.account.db.InvoiceLine" >
        <hilite strong="true" color="default" if="typeSelect != 0"/>
       	<field name="product.code" width="120"/>
        <field name="productName"/>
        <field name="qty" aggregate="sum"/>
        <field name="priceDiscounted" title="Unit price W.T." x-scale="2"/>
        <field name="inTaxPrice" x-scale="2"/>
        <field name="unit" form-view="unit-form" grid-view="unit-grid"/>
        <field name="exTaxTotal" aggregate="sum"/>
	    <field name="inTaxTotal" aggregate="sum"/>
	    <field name="typeSelect" hidden="true"/>
    </grid>

	<grid name="invoice-line-menu-grid" title="Invoice lines" model="com.axelor.apps.account.db.InvoiceLine" canNew="false" canEdit="false" canSave="false" canDelete="false" canArchive="false" edit-icon="true" orderBy="-invoice.invoiceDate">
  	 <hilite color="primary" if="$get('invoice.statusSelect') == 1"/>
     <hilite color="danger" if="$get('invoice.statusSelect') == 3 &amp;&amp; $get('invoice.amountRemaining') &gt; 0 &amp;&amp; $moment($get('invoice.dueDate')).diff(todayDate,'days') &lt; 0"/>
     <hilite color="warning" if="$get('invoice.statusSelect') == 3 &amp;&amp; $get('invoice.amountRemaining') &gt; 0 &amp;&amp; $moment($get('invoice.dueDate')).diff(todayDate,'days') &gt;= 0 &amp;&amp; $moment($get('invoice.dueDate')).diff(todayDate,'days') &lt;= 5"/>
     <hilite color="success" if="$get('invoice.statusSelect') == 3 &amp;&amp; $get('invoice.amountRemaining') == 0"/>
  		<field name="invoice.partner.partnerSeq" width="120" title="Partner code"/>
  		<field name="invoice.partner.simpleFullName" title="Partner"/>
  		<field name="invoice.invoiceId" width="120"/>
 		<field name="invoice.invoiceDate" title="Date"/>
  		<field name="invoice.statusSelect" title="invoiceLineMenu.status"/>
  		<field name="invoice.address.addressL7Country"/>
  		<field name="product.code" title="product.code" width="120"/>
  		<field name="productName" width="170"/>
  		<field name="qty" width="50" aggregate="sum"/>
  		<field name="priceDiscounted" title="Unit price W.T." x-scale="2"/>
  		<field name="unit" width="60" form-view="unit-form" grid-view="unit-grid"/>
  		<field name="exTaxTotal" aggregate="sum"/>
  		<field name="invoice.currency" width="85"/>
  		<field name="companyExTaxTotal" title="WT amount in company currency" aggregate="sum" hidden="false"/>
  		<field name="invoice.company.currency" title="Company currency" width="125"/>
  		<field name="invoice.amountRemaining" hidden="true"/>
  		<field name="invoice.dueDate" hidden="true"/>
	</grid>

	<form name="invoice-line-form" title="Invoice line" model="com.axelor.apps.account.db.InvoiceLine" width="large" readonlyIf="$isReadOnly"
		  onNew="action-account-invoice-line-onnew-group"
		  onLoad="action-group-account-invoice-line-onload">
		<panel name="titlePanel" hideIf="typeSelect != 1">
			<field name="productName"  title="Title" requiredIf="typeSelect == 1"  colSpan="9"/>
			<field name="typeSelect" colSpan="3" onChange="action-invoice-line-method-empty-line" selection-in="[0,1]" />
		</panel>
		<panel-tabs name="mainPanelTab" hideIf="typeSelect == 1">
			<panel name="informationsPanel" title="Information">
				<field name="product" canEdit="false" onChange="action-group-account-invoice-line-product-onchange" onSelect="action-invoice-line-attrs-set-product-domain-onselect" form-view="product-form" grid-view="product-grid"/>
				<field name="$isFilterOnSupplier" title="Filter on supplier" type="boolean" widget="boolean-switch"  colSpan="2" if="__config__.app.isApp('purchase') &amp;&amp; __config__.app.getApp('purchase').getManageSupplierCatalog()"/>
				<field name="typeSelect" colSpan="3" onChange="action-invoice-line-method-empty-line" selection-in="[0,1]"  />
				<field name="packPriceSelect" colSpan="3" showIf="typeSelect == 2" onChange="action-group-invoice-line-pack-price-select-onchange" if="(__config__.app.isApp('sale') &amp;&amp; __config__.app.getApp('sale').getProductPackMgt())" />
				<field name="productName" colSpan="12" requiredIf="typeSelect != 1"/>
				<field name="qty" colSpan="3" required="true" readonlyIf="isSubLine" onChange="action-group-account-invoice-line-qty-onchange"/>
				<field name="unit" colSpan="3" canEdit="false" form-view="unit-form" grid-view="unit-grid" readonlyIf="typeSelect == 2 || isSubLine"/>
				<field name="price" colSpan="3" required="true" onChange="action-invoice-line-method-onchange-price,action-invoice-line-method-compute,action-invoice-line-method-compute-analytic-distribution,action-budget-validate-exceed-line-amount" hidden="true"/>
				<field name="inTaxPrice" colSpan="3" required="true" onChange="action-invoice-line-method-onchange-intaxprice,action-invoice-line-method-compute,action-invoice-line-method-compute-analytic-distribution,action-budget-validate-exceed-line-amount" hidden="true"/>
				<panel name="discountPanel" colSpan="12">
					<field name="discountTypeSelect" colSpan="3" onChange="action-invoice-line-method-compute,action-invoice-line-attrs-discountamount-title,action-invoice-line-method-compute-analytic-distribution,action-budget-validate-exceed-line-amount"/>
					<field name="discountAmount" colSpan="3" onChange="action-invoice-line-method-compute,action-invoice-line-method-compute-analytic-distribution,action-budget-validate-exceed-line-amount" hideIf="discountTypeSelect == 3"/>
					<field name="priceDiscounted" colSpan="3" hidden="true" readonly="true"/>
				</panel>
				<field name="taxLine" canEdit="false" onChange="action-invoice-line-method-convert-tax,action-invoice-line-method-compute,action-invoice-line-method-compute-analytic-distribution,action-budget-validate-exceed-line-amount" grid-view="tax-line-grid" form-view="tax-line-form"/>
				<field name="exTaxTotal" colSpan="3" readonly="true"/>
				<field name="inTaxTotal" colSpan="3" readonly="true"/>
				<field name="isSubLine" hideIf="!isSubLine" if="(__config__.app.isApp('sale') &amp;&amp; __config__.app.getApp('sale').getProductPackMgt())" colSpan="4"/>
				<field name="parentLine" hideIf="!isSubLine || parentLine == null" />
				<field name="$isReadOnly" hidden="true"/>
				<field name="taxEquiv" hidden="true" grid-view="tax-equiv-grid" form-view="tax-equiv-form"/>
				<field name="invoice" hidden="true" />
        		<field name="companyExTaxTotal" hidden="true"/>
      			<field name="companyInTaxTotal" hidden="true"/>
				<panel name="descriptionPanel" title="Description" colSpan="12">
					<field name="description" showTitle="false" colSpan="12" widget="html" x-lite="true"/>
				</panel>
			</panel>
			<panel name="packPanel" title="Pack lines" showIf="typeSelect == 2" readonlyIf="packPriceSelect == 0">
				<panel-related name="subLineListPanel" field="subLineList" onChange="action-invoice-line-attrs-compute-total-pack" colSpan="12" canNew="false" canRemove="false" form-view="invoice-line-form" grid-view="invoice-line-grid"/>
				<field name="totalPack" readonly="true"/>
			</panel>
			<panel name="accountingPanel" title="Accounting">
				<field name="account" colSpan="9" onSelect="action-invoice-line-method-filter-account" canEdit="false" onChange="action-attrs-account-invoice-line-account-onchange"/>
				<panel name="assetsPanel"  colSpan="3" itemSpan="12">
					<field name="fixedAssets" showTitle="false" showIf="$readonly()">
						<viewer depends="fixedAssets">
							<![CDATA[
								<span class="label label-default" style="background-color: #B6473F; margin: 10px 0 !important; padding: 5px 0 !important; display: inline-table; line-height: initial;" ng-show="record.fixedAssets" x-translate>Fixed Assets</span>
							]]>
						</viewer>
					</field>
					<field name="fixedAssets"  showTitle="true" hideIf="$readonly() || $contains([3,4], $_operationTypeSelect)" widget="boolean-switch" onChange="action-invoice-line-method-get-account"/>
					<field name="$_operationTypeSelect" hidden="true"/>
					<field name="$_company" type="many-to-one" target="com.axelor.apps.base.db.Company" hidden="true"/>
					<field name="fixedAssetCategory" canEdit="false" domain="self.company = :_company" form-view="fixed-asset-category-form" grid-view="fixed-asset-category-grid" showIf="fixedAssets &amp;&amp; $contains([1,2], $_operationTypeSelect)"/>
				</panel>
			</panel>

			<panel name="budgetPanel" title="Budget" if="__config__.app.isApp('budget')">
				<field name="companyExTaxTotal" title="Total W.T." colSpan="6" if="__config__.app.getApp('budget').getManageMultiBudget()" readonly="true" hidden="false">
					<viewer depends="companyExTaxTotal,$currencySymbol">
						<![CDATA[
							<dd>{{record.companyExTaxTotal}} {{record.$currencySymbol}}</dd>
						]]>
					</viewer>
				</field>
				<field name="budgetDistributionSumAmount" colSpan="6" if="__config__.app.getApp('budget').getManageMultiBudget()" readonly="true"/>
				<field name="budget" if="!__config__.app.getApp('budget').getManageMultiBudget()" canEdit="false" domain="self.statusSelect = 2"/>
				<panel-related name="budgetDistributionListPanel" field="budgetDistributionList" editable="true" colSpan="12" if="__config__.app.getApp('budget').getManageMultiBudget()" onChange="action-budget-validate-exceed-line-amount,action-invoice-order-method-compute-budget-distribution-sum-amount"/>
				<field name="$currencySymbol" hidden="true"/>
			</panel>
			<panel name="projectPanel" if="__config__.app.isApp('business-project') &amp;&amp; __config__.app.getApp('business-project').getProjectInvoiceLines()" title="Business Project" if-module="axelor-business-project" >
				<field name="project" canEdit="false" onSelect="action-invoice-line-attrs-domain-project" form-view="project-form" grid-view="project-grid"/>
				<panel-dashlet name="teamTaskListPanel" title="Related tasks" action="action-invoice-line-view-team-tasks" colSpan="12"/>
			</panel>
			<panel name="analyticDistributionPanel" title="Analytics" if-module="axelor-supplychain" if="__config__.app.isApp('account') &amp;&amp; __config__.app.getApp('account').getManageAnalyticAccounting()" onTabSelect="action-invoice-line-attrs-read-only-distribution-lines">
				<field name="analyticDistributionTemplate" readonlyIf="!account.analyticDistributionAuthorized" grid-view="analytic-distribution-template-grid" form-view="analytic-distribution-template-form" canEdit="false" onChange="action-invoice-line-method-create-distribution" onSelect="action-invoice-line-attrs-set-domain-analytic-distribution-template"/>
				<panel-related name="analyticMoveLineListPanel" field="analyticMoveLineList" grid-view="analytic-move-line-distribution-grid" form-view="analytic-move-line-distribution-form" colSpan="12" onChange="action-attrs-account-invoice-line-onnew-onload"/>
				<field name="account.analyticDistributionAuthorized" hidden="true" />
			</panel>
			<panel name="configurationPanel" title="Configuration" if-module="axelor-supplychain" if="__config__.app.isApp('supplychain')">

				<field name="saleOrderLine" if="__config__.app.isApp('supplychain')" if-module="axelor-supplychain" form-view="sale-order-line-invoice-form" grid-view="sale-order-line-invoice-grid" domain="(self.saleOrder.statusSelect = 3 OR self.saleOrder.statusSelect = 4 ) AND EXISTS(SELECT i FROM Invoice i WHERE i = :invoice AND self.saleOrder.clientPartner = i.partner )"/>
				<field name="purchaseOrderLine" if-module="axelor-supplychain" if="__config__.app.isApp('supplychain')" form-view="purchase-order-line-form" grid-view="purchase-order-line-grid"/>

			</panel>
		</panel-tabs>
	</form>

	<form name="invoice-line-client-form" title="Invoice line" model="com.axelor.apps.account.db.InvoiceLine" width="large"
		  onNew="action-account-invoice-line-onnew-group"
		  onLoad="action-attrs-account-invoice-line-onnew-onload,action-invoice-line-attrs-readonly-form">
		<panel name="titlePanel">
			<field name="typeSelect" onChange="action-invoice-line-method-empty-line"/>
			<field name="productName" showIf="typeSelect == 1" title="Title" requiredIf="typeSelect == 1"/>
		</panel>
		<panel-tabs name="mainPanelTab" hideIf="typeSelect == 1">
			<panel name="informationsPanel" title="Informations">
				<field name="product" onChange="action-group-account-invoice-line-product-onchange" form-view="product-form" grid-view="product-grid" canView="false"/>
				<field name="productName" requiredIf="!typeSelect == 1"/>
				<field name="qty" required="true" onChange="action-group-account-invoice-line-qty-onchange"/>
				<field name="price" required="true" onChange="action-invoice-line-method-onchange-price,action-invoice-line-method-compute,action-invoice-line-method-compute-analytic-distribution" hidden="true"/>
				<field name="inTaxPrice" required="true" onChange="action-invoice-line-method-onchange-intaxprice,action-invoice-line-method-compute,action-invoice-line-method-compute-analytic-distribution" hidden="true"/>
				<field name="unit" canEdit="false" form-view="unit-form" grid-view="unit-grid"/>
				<field name="priceDiscounted" hidden="true"/>
				<field name="taxLine" canEdit="false" onChange="action-invoice-line-method-convert-tax,action-invoice-line-method-compute,action-invoice-line-method-compute-analytic-distribution" grid-view="tax-line-grid" form-view="tax-line-form"/>
				<field name="exTaxTotal" readonly="true"/>
				<field name="inTaxTotal" readonly="true"/>
				<field name="invoice" hidden="true" />
				<panel name="discountPanel" title="Discount" colSpan="12">
					<field name="discountTypeSelect" onChange="action-invoice-line-method-compute,action-invoice-line-attrs-discountamount-title,action-invoice-line-method-compute-analytic-distribution"/>
					<field name="discountAmount" onChange="action-invoice-line-method-compute,action-invoice-line-method-compute-analytic-distribution" hideIf="discountTypeSelect == 3"/>
				</panel>
			</panel>
		</panel-tabs>
	</form>

	<form name="invoice-line-menu-form" title="Invoice line" model="com.axelor.apps.account.db.InvoiceLine" width="large"
		canNew="false" canEdit="false" canSave="false" canDelete="false" canCopy="false" canArchive="false"
		  onLoad="action-group-invoice-line-menu-form-onload">
		<panel name="mainPanel">
			<field name="invoice.company" colSpan="12"/>
			<field name="invoice.partner" colSpan="3"/>
			<field name="invoice.invoiceId" colSpan="3"/>
			<field name="invoice.invoiceDate" colSpan="3"/>
			<field name="invoice.currency" colSpan="3"/>
		</panel>
		<panel-include view="invoice-line-form"/>
	</form>
	        
    <action-method name="action-invoice-line-method-empty-line">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="emptyLine"/>
	</action-method>
    
    <action-method name="action-invoice-line-method-create-distribution">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="createAnalyticDistributionWithTemplate"/>
	</action-method>
    
    <action-attrs name="action-invoice-line-attrs-read-only-distribution-lines">
		<attribute name="readonly" for="analyticMoveLineList" expr="eval: __config__.app.getApp('account').getAnalyticDistributionTypeSelect() != 1 || !account?.analyticDistributionAuthorized"/>
	</action-attrs>
	
	<action-attrs name="action-invoice-line-attrs-set-domain-analytic-distribution-template">
		<attribute name="domain" for="analyticDistributionTemplate" expr="eval: &quot; self.company.id = ${_parent?.company.id} &quot;"/>
	</action-attrs>
    
    <action-attrs name="action-invoice-line-attrs-domain-project">
    	<attribute name="domain" for="project" expr="eval: &quot; self.clientPartner.id = ${_parent?.partner.id} AND self.isBusinessProject = true &quot;" if="_parent?._model == 'com.axelor.apps.account.db.Invoice' &amp;&amp; (_parent?.operationTypeSelect == 3 || _parent?.operationTypeSelect == 4)"/>
    	<attribute name="domain" for="project" expr="eval: &quot; self.isBusinessProject = true &quot;" if="_parent?._model == 'com.axelor.apps.account.db.Invoice' &amp;&amp; (_parent?.operationTypeSelect == 1 || _parent?.operationTypeSelect == 2)"/>
    	<attribute name="domain" for="project" expr="eval: &quot; self.clientPartner.id = ${invoice.partner.id} AND self.isBusinessProject = true &quot;" if="invoice != null &amp;&amp; (invoice.operationTypeSelect == 3 || invoice.operationTypeSelect == 4) &amp;&amp; _parent?._model != 'com.axelor.apps.account.db.Invoice'"/>
    	<attribute name="domain" for="project" expr="eval: &quot; self.isBusinessProject = true &quot;" if="invoice != null &amp;&amp; (invoice.operationTypeSelect == 1 || invoice.operationTypeSelect == 2) &amp;&amp; _parent?._model != 'com.axelor.apps.account.db.Invoice'"/>
    </action-attrs>

	<action-attrs name="action-invoice-line-attrs-readonly-form">
		<attribute name="readonly" for="titlePanel" expr="eval: __parent__?.statusSelect &gt; 1"/>
		<attribute name="readonly" for="informationsPanel" expr="eval: __parent__?.statusSelect &gt; 1"/>
		<attribute name="readonly" for="description" expr="eval: __parent__?.statusSelect &gt; 1"/>
		<attribute name="readonly" for="projectPanel" expr="eval: __parent__?.statusSelect &gt; 1"/>
		<attribute name="readonly" for="analyticDistributionPanel" expr="eval: __parent__?.statusSelect &gt; 2"/>
		<attribute name="readonly" for="budgetPanel" expr="eval: __parent__?.statusSelect &gt; 1"/>

		<attribute name="readonly" for="accountingPanel" expr="eval: __parent__?.statusSelect &gt; 2"/>
	</action-attrs>

	<!-- TODO : to test, when invoice lines menu entry will be available -->
	<action-attrs name="action-invoice-line-attrs-readonly-menu-form">
		<attribute name="readonly" for="titlePanel" expr="eval: invoice.statusSelect &gt; 1"/>
		<attribute name="readonly" for="informationsPanel" expr="eval: invoice.statusSelect &gt; 1"/>
		<attribute name="readonly" for="description" expr="eval: invoice.statusSelect &gt; 1"/>
		<attribute name="readonly" for="projectPanel" expr="eval: invoice.statusSelect &gt; 1"/>
		<attribute name="readonly" for="analyticDistributionPanel" expr="eval: invoice.statusSelect &gt; 1"/>
		<attribute name="readonly" for="budgetPanel" expr="eval: invoice.statusSelect &gt; 1"/>

		<attribute name="readonly" for="accountingPanel" expr="eval: invoice.statusSelect &gt; 2"/>
	</action-attrs>

	<action-attrs name="action-invoice-line-attrs-hidden-menu-form">
		<!-- Show Elements -->
		<attribute name="hidden" for="saleOrder" expr="eval: invoice?.operationTypeSelect != 3 &amp;&amp; invoice?.operationTypeSelect != 4" if="__config__.app.isApp('business-project')"/>
		<attribute name="hidden" for="purchaseOrder" expr="eval: invoice?.operationTypeSelect != 1 &amp;&amp; invoice?.operationTypeSelect != 2" if="__config__.app.isApp('business-project')"/>
		<attribute name="hidden" for="saleOrderLine" expr="eval: invoice?.operationTypeSelect != 3 &amp;&amp; invoice?.operationTypeSelect != 4" if="__config__.app.isApp('business-project')"/>
		<attribute name="hidden" for="purchaseOrderLine" expr="eval: invoice?.operationTypeSelect != 1 &amp;&amp; invoice?.operationTypeSelect != 2" if="__config__.app.isApp('business-project')"/>
		<attribute name="hidden" for="budgetPanel" expr="eval: invoice?.operationTypeSelect != 1 &amp;&amp; invoice?.operationTypeSelect != 2" if="__config__.app.isApp('business-project')" />
		<attribute name="hidden" for="$isFilterOnSupplier" expr="eval: invoice?.operationTypeSelect &gt; 2" />
		<attribute name="hidden" for="accountingPanel" expr="eval:invoice?.operationSubTypeSelect==2"/>
	</action-attrs>

	<action-attrs name="action-invoice-line-attrs-set-product-domain-onselect">
  		<attribute if="__parent__.operationTypeSelect &lt; 3  &amp;&amp; __config__.app.isApp('purchase')  &amp;&amp;  __config__.app.getApp('purchase').getManageSupplierCatalog()" name="domain" expr="eval: isFilterOnSupplier ? &quot; self.isModel = false and self.id IN (SELECT product.id FROM SupplierCatalog WHERE supplierPartner.id = ${__parent__?.partner?.id}) &quot; : &quot; self.isModel = false &quot;" for="product"/>
  		<attribute  name="domain"  for="product" expr="eval: &quot; self.isModel = false &quot;" if="__parent__.operationTypeSelect > 2"/>
	</action-attrs>

    <!-- ACTION GROUPs -->
    <action-group name="action-account-invoice-line-onnew-group">
	    <action name="action-invoice-line-record-new"/>
	    <action name="action-invoice-line-record-project"/>
	    <action name="action-invoice-line-record-operation-type"/>
	    <action name="action-attrs-account-invoice-line-onnew-onload"/>
	    <action name="action-invoice-line-attrs-sub-line" if="(__config__.app.isApp('supplychain') &amp;&amp; __config__.app.getApp('sale').getProductPackMgt())"/>
		<action name="action-budget-distribution-attrs-budget-amount-available" if="__config__.app.isApp('budget') &amp;&amp; __config__.app.getApp('budget').getManageMultiBudget()"/>
    </action-group>

	<action-group name="action-group-account-invoice-line-onload">
		<action name="action-invoice-sub-line-record-form-isReadonly" if="(__config__.app.isApp('supplychain') &amp;&amp; __config__.app.getApp('sale').getProductPackMgt())"/>
		<action name="action-attrs-account-invoice-line-onnew-onload"/>
		<action name="action-invoice-line-attrs-readonly-form"/>
		<action name="action-invoice-line-record-operation-type"/>
		<action name="action-budget-distribution-attrs-budget-amount-available" if="__config__.app.isApp('budget') &amp;&amp; __config__.app.getApp('budget').getManageMultiBudget()"/>
	</action-group>

    <action-group name="action-group-account-invoice-line-product-onchange">
    	<action name="action-invoice-line-method-get-product-information"/>
    	<action name="action-invoice-line-method-get-product-price" if="__config__.app.isApp('supplychain') &amp;&amp; (__config__.app.isApp('sale') &amp;&amp; __config__.app.getApp('sale').getProductPackMgt())"/>
    	<action name="action-invoice-line-method-compute"/>
    	<action name="action-invoice-line-method-get-and-compute-analytic-distribution"/>
    	<action name="action-budget-validate-exceed-line-amount"/>
    	<action name="action-invoice-line-attrs-compute-total-pack" if="(__config__.app.isApp('supplychain') &amp;&amp; __config__.app.getApp('sale').getProductPackMgt())"/>
    	<action name="action-invoice-line-method-get-fixed-asset-category" if="__config__.app.isApp('account')"/>
    	<action name="action-attrs-account-invoice-line-onnew-onload"/>
    </action-group>
    
    <action-group name="action-group-account-invoice-line-qty-onchange">
		<action name="action-invoice-line-method-get-discount"/>
		<action name="action-invoice-line-method-compute"/>
		<action name="action-invoice-line-method-compute-analytic-distribution"/>
		<action name="action-budget-validate-exceed-line-amount"/>
		<action name="action-invoice-method-title-subline-update-qty" if="(__config__.app.isApp('supplychain') &amp;&amp; __config__.app.getApp('sale').getProductPackMgt())"/>
		<action name="action-invoice-line-attrs-compute-total-pack" if="(__config__.app.isApp('supplychain') &amp;&amp; __config__.app.getApp('sale').getProductPackMgt())"/>
	</action-group>

	<action-group name="action-group-invoice-line-pack-price-select-onchange">
		<action name="action-invoice-subline-method-reset-pack-data"/>
		<action name="action-attrs-account-invoice-line-onnew-onload"/>
	</action-group>
	
	<action-group name="action-group-invoice-line-menu-form-onload">
		<action name="action-attrs-account-invoice-line-onnew-onload"/>
		<action name="action-invoice-line-attrs-readonly-menu-form"/>
		<action name="action-invoice-line-attrs-hidden-menu-form"/>
	</action-group>

    <!--     ACTION RECORDS -->
    
    <action-record name="action-invoice-line-record-new" model="com.axelor.apps.account.db.InvoiceLine">
    	<field name="qty" expr="eval: 1"/>
    	<field name="$isFilterOnSupplier" expr="eval:true"/>
    </action-record>

    <action-record name="action-invoice-line-record-operation-type" model="com.axelor.apps.account.db.InvoiceLine">
    	<field name="$_operationTypeSelect" expr="eval: __parent__.operationTypeSelect"/>
    	<field name="$_company" expr="eval:__parent__?.company"/>
    </action-record>
    
    <action-record name="action-invoice-sub-line-record-form-isReadonly" model="com.axelor.apps.account.db.InvoiceLine">
    	<field name="$isReadOnly" expr="eval: true" if="_parent?._model == 'com.axelor.apps.account.db.Invoice' &amp;&amp; isSubLine"/>
    </action-record>

	<!-- ACTION METHOD -->
	
	<action-method name="action-invoice-line-method-get-and-compute-analytic-distribution">
 		<call class="com.axelor.apps.account.web.InvoiceLineController" method="getAndComputeAnalyticDistribution"/>
	</action-method>
	
	<action-method name="action-invoice-line-method-compute-analytic-distribution">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="computeAnalyticDistribution"/>
	</action-method>
	
	<action-method name="action-invoice-method-title-subline-update-qty">
		<call class="com.axelor.apps.supplychain.web.InvoiceLineController" method="updateSubLineQty"/>
	</action-method>

	<action-method name="action-invoice-line-method-convert-tax">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="convertUnitPrice"/>
	</action-method>
	
	<action-method name="action-invoice-line-method-compute">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="compute"/>
	</action-method>
	
	<action-method name="action-invoice-line-method-get-product-information">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="getProductInformation"/>
	</action-method>
	
	<action-method name="action-invoice-line-method-get-product-price">
		<call class="com.axelor.apps.supplychain.web.InvoiceLineController" method="getProductPrice"/>
	</action-method>

	<action-method name="action-invoice-line-method-get-discount">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="getDiscount"/>
	</action-method>

	<action-method name="action-invoice-line-method-get-account">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="getAccount"/>
	</action-method>

	<action-method name="action-invoice-subline-method-reset-pack-data">
		<call class="com.axelor.apps.supplychain.web.InvoiceLineController" method="resetPackData"/>
	</action-method>
	
	<action-method name="action-invoice-line-method-onchange-price">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="updateInTaxPrice"/>
	</action-method>
	
	<action-method name="action-invoice-line-method-onchange-intaxprice">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="updatePrice"/>
  	</action-method> 

	<action-method name="action-invoice-line-method-filter-account">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="filterAccount"/>
	</action-method>
	
	<action-method name="action-invoice-line-method-get-fixed-asset-category">
		<call class="com.axelor.apps.account.web.InvoiceLineController" method="getFixedAssetCategory"/>
	</action-method>

	<action-method name="action-invoice-order-method-compute-budget-distribution-sum-amount">
		<call class="com.axelor.apps.supplychain.web.InvoiceLineController" method="computeBudgetDistributionSumAmount"/>
	</action-method>

	<!-- ACTION ATTRS -->
	<action-attrs name="action-attrs-account-invoice-line-onnew-onload">
		<!-- Show Elements -->
		<attribute name="title" for="projectPanel" expr="eval: __config__.app.getApp('project').getProjectLabel()" if="__config__.app.isApp('business-project') &amp;&amp; __config__.app.isApp('project') &amp;&amp; !com.google.common.base.Strings.isNullOrEmpty(__config__.app.getApp('project').getProjectLabel())"/>
		<attribute name="title" for="project" expr="eval:  __config__.app.getApp('project').getProjectLabel()" if="__config__.app.isApp('business-project') &amp;&amp; __config__.app.isApp('project') &amp;&amp; !com.google.common.base.Strings.isNullOrEmpty(__config__.app.getApp('project').getProjectLabel())"/>
		<attribute name="hidden" for="saleOrder" expr="eval: __parent__?.operationTypeSelect != 3 &amp;&amp; __parent__?.operationTypeSelect != 4" if="__config__.app.isApp('business-project')"/>
		<attribute name="hidden" for="purchaseOrder" expr="eval: __parent__?.operationTypeSelect != 1 &amp;&amp; __parent__?.operationTypeSelect != 2" if="__config__.app.isApp('business-project')"/>
		<attribute name="hidden" for="saleOrderLine" expr="eval: __parent__?.operationTypeSelect != 3 &amp;&amp; __parent__?.operationTypeSelect != 4" if="__config__.app.isApp('business-project')"/>
		<attribute name="hidden" for="purchaseOrderLine" expr="eval: __parent__?.operationTypeSelect != 1 &amp;&amp; __parent__?.operationTypeSelect != 2" if="__config__.app.isApp('business-project')"/>
		<attribute name="hidden" for="budgetPanel" expr="eval: __parent__?.operationTypeSelect != 1 &amp;&amp; __parent__?.operationTypeSelect != 2" if="__config__.app.isApp('business-project')" />
		<attribute name="hidden" for="$isFilterOnSupplier" expr="eval: __parent__?.operationTypeSelect &gt; 2" />
		<attribute name="hidden" for="accountingPanel" expr="eval:__parent__?.operationSubTypeSelect==2"/>
		<!-- Scale and Precision -->
		<attribute name="scale" for="price" expr="eval: __config__.app.getNbDecimalDigitForUnitPrice()"/>
		<attribute name="scale" for="inTaxPrice" expr="eval: __config__.app.getNbDecimalDigitForUnitPrice()"/>
		<attribute name="scale" for="priceDiscounted" expr="eval: __config__.app.getNbDecimalDigitForUnitPrice()"/>
		<attribute name="scale" for="discountAmount" expr="eval: __config__.app.getNbDecimalDigitForUnitPrice()"/>

		<!-- Hide ATI OR depending on pack configuration -->
		<attribute name="hidden" for="exTaxTotal,price" expr="eval: __parent__.inAti || typeSelect == 2 &amp;&amp; packPriceSelect == 1 || isSubLine &amp;&amp; parentLine?.packPriceSelect == 0" if="__parent__?._model == 'com.axelor.apps.account.db.Invoice'"/>
		<attribute name="hidden" for="subLineList.exTaxTotal,subLineList.price" expr="eval: __parent__.inAti || typeSelect == 2 &amp;&amp; packPriceSelect == 0" if="__parent__?._model == 'com.axelor.apps.account.db.Invoice'"/>
		<attribute name="hidden" for="inTaxTotal,inTaxPrice" expr="eval: !__parent__.inAti || typeSelect == 2 &amp;&amp; packPriceSelect == 1 || isSubLine &amp;&amp; parentLine?.packPriceSelect == 0" if="__parent__?._model == 'com.axelor.apps.account.db.Invoice'"/>
		<attribute name="hidden" for="subLineList.inTaxTotal,subLineList.inTaxPrice" expr="eval: !__parent__.inAti || typeSelect == 2 &amp;&amp; packPriceSelect == 0" if="__parent__?._model == 'com.axelor.apps.account.db.Invoice'"/>
		
		<attribute name="hidden" for="exTaxTotal,price" expr="eval: saleOrder?.inAti || typeSelect == 2 &amp;&amp; packPriceSelect == 1 || isSubLine &amp;&amp; parentLine?.packPriceSelect == 0" if="invoice != null &amp;&amp; __parent__?._model != 'com.axelor.apps.account.db.Invoice'" />
		<attribute name="hidden" for="subLineList.exTaxTotal,subLineList.price" expr="eval: saleOrder?.inAti || typeSelect == 2 &amp;&amp; packPriceSelect == 0" if="invoice != null &amp;&amp; __parent__?._model != 'com.axelor.apps.account.db.Invoice'" />
		<attribute name="hidden" for="inTaxTotal,inTaxPrice" expr="eval: !saleOrder?.inAti || typeSelect == 2 &amp;&amp; packPriceSelect == 1 || isSubLine &amp;&amp; parentLine?.packPriceSelect == 0" if="invoice != null &amp;&amp; __parent__?._model != 'com.axelor.apps.account.db.Invoice'" />
		<attribute name="hidden" for="subLineList.inTaxTotal,subLineList.inTaxPrice" expr="eval: !saleOrder?.inAti || typeSelect == 2 &amp;&amp; packPriceSelect == 0" if="invoice != null &amp;&amp; __parent__?._model != 'com.axelor.apps.account.db.Invoice'" />
		
		<attribute name="hidden" for="exTaxTotal,price" expr="eval: __parent__?.__parent__?.inAti || __parent__?.packPriceSelect == 0" if="isSubLine &amp;&amp; __parent__?._model == 'com.axelor.apps.account.db.InvoiceLine'" />
		<attribute name="hidden" for="inTaxTotal,inTaxPrice" expr="eval: !__parent__?.__parent__?.inAti || __parent__?.packPriceSelect == 0" if="isSubLine &amp;&amp; __parent__._model == 'com.axelor.apps.account.db.InvoiceLine'" />
		
		<attribute name="hidden" for="discount,taxLine" expr="eval:packPriceSelect == 1" if="typeSelect == 2"/>
		<attribute name="hidden" for="discount,taxLine" expr="eval:__parent__?.packPriceSelect == 0"  if="isSubLine &amp;&amp; __parent__._model == 'com.axelor.apps.account.db.InvoiceLine'"/>
		<attribute name="hidden" for="discount,taxLine" expr="eval:parentLine?.packPriceSelect == 0"  if="isSubLine &amp;&amp; __parent__._model == 'com.axelor.apps.account.db.Invoice'"/>
		
		<!-- Show Price Discounted -->
		<attribute name="hidden" for="priceDiscounted" expr="eval: priceDiscounted == price" if="__parent__?._model == 'com.axelor.apps.account.db.Invoice' &amp;&amp; !__parent__?.inAti"/>
		<attribute name="hidden" for="priceDiscounted" expr="eval: priceDiscounted == inTaxPrice" if="__parent__?._model == 'com.axelor.apps.account.db.Invoice' &amp;&amp; __parent__?.inAti"/>
		
		<attribute name="required" for="analyticDistributionTemplate" expr="__parent__?.statusSelect &gt; 1 &amp;&amp; analyticMoveLineList.isEmpty() &amp;&amp; account?.analyticDistributionAuthorized &amp;&amp; account?.analyticDistributionRequiredOnInvoiceLines" if="__config__.app.isApp('account') &amp;&amp; __config__.app.getApp('account').getManageAnalyticAccounting()" />
		
	</action-attrs>

  	<action-attrs name="action-attrs-account-invoice-line-account-onchange">
    	<attribute name="required" for="analyticDistributionTemplate" expr="_parent?.statusSelect &gt; 1 &amp;&amp; analyticMoveLineList.isEmpty() &amp;&amp; account?.analyticDistributionAuthorized &amp;&amp; account?.analyticDistributionRequiredOnInvoiceLines" if="__config__.app.isApp('account') &amp;&amp; __config__.app.getApp('account').getManageAnalyticAccounting()" />
  	</action-attrs>

	<action-attrs name="action-invoice-line-attrs-sub-line">
	  <attribute if="eval: __parent__.typeSelect == 2" name="value" expr="eval: true" for="isSubLine"/>
	</action-attrs>

    <action-attrs name="action-invoice-line-attrs-discountamount-title">
		<attribute name="title" for="discountAmount" expr="eval: com.axelor.i18n.I18n.get('Discount rate')" if="discountTypeSelect == 1"/>
		<attribute name="title" for="discountAmount" expr="eval: com.axelor.i18n.I18n.get('Discount amount')" if="discountTypeSelect == 2"/>
	</action-attrs>
	
	<action-record name="action-invoice-line-record-project" model="com.axelor.apps.account.db.InvoiceLine" if-module="axelor-business-project">
		<field name="project" expr="eval: _parent?.project" if="__config__.app.isApp('business-project')" />
	</action-record>

	<action-attrs name="action-invoice-line-attrs-compute-total-pack">
		<attribute name="value" for="totalPack" expr="eval:subLineList.collect{it->it.inTaxTotal}.sum()" if="typeSelect == 2 &amp;&amp; subLineList != null &amp;&amp; (__config__.app.isApp('sale') &amp;&amp; __config__.app.getApp('sale').getProductPackMgt())"/>
	</action-attrs>

	<action-view name="action-invoice-line-view-team-tasks" title="Related tasks" model="com.axelor.team.db.TeamTask">
		<view type="grid" name="team-task-grid"/>
		<view type="form" name="team-task-form"/>
		<domain>self.invoiceLine = :id</domain>
	</action-view>

	<search-filters name="invoice-line-filters" model="com.axelor.apps.account.db.InvoiceLine" title="Invoice line filters">
		<field name="invoice.invoiceDate" title="Invoice Date"/>
	</search-filters>

</object-views>
