<?xml version="1.0" encoding="utf-8"?>
<action-builders xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  
  <action-builder name="action-create-invoice-from-timesheet" 
  	isJson="false" 
  	typeSelect="0" 
  	appBuilder="PRD"
  	model="com.axelor.apps.hr.db.Timesheet"
  	targetModel="com.axelor.apps.account.db.Invoice">
  	<lines>
	  	<line metaField="partner" metaModel="Invoice" valueField="company" valueModel="Timesheet" value="$.company.partner" />
	  	<line metaField="company" metaModel="Invoice" valueField="company" valueModel="Timesheet" value="$.company" />
	  	<line metaField="currency" metaModel="Invoice"  valueField="company"  valueModel="Timesheet" value="$.company.currency" />
	  	<line metaField="operationTypeSelect" metaModel="Invoice"  value="3"/>
	  	<line metaField="paymentCondition" metaModel="Invoice"  filter="self.code = '15D_EOM'"/>
	  	<line metaField="paymentMode" metaModel="Invoice"  filter="self.code = 'OUT_WT'"/>
	  	<line name="total" value="$.timesheetLineList.sum($.hoursDuration*$$.user.employee.hourlyRate)" dummy="true"/>
	  	<line metaField="exTaxTotal" metaModel="Invoice"  value="_$.total" />
	  	<line metaField="inTaxTotal" metaModel="Invoice"  value="_$.total" />
	  	<line metaField="invoiceLineList" metaModel="Invoice" valueField="timesheetLineList" valueModel="Timesheet" value="$.timesheetLineList">
		  	<subLines>
		  		<line metaField="exTaxTotal" metaModel="InvoiceLine" value="$.hoursDuration*$$.user.employee.hourlyRate" />
		  		<line metaField="price"  metaModel="InvoiceLine" value="$$.user.employee.hourlyRate" />
		  		<line metaField="product" metaModel="InvoiceLine" valueModel="TimesheetLine" valueField="product" value="$.product" />
		  		<line metaField="productName" metaModel="InvoiceLine" valueModel="TimesheetLine" valueField="product" value="$.product.name" />
		  		<line metaField="qty" metaModel="InvoiceLine" valueModel="TimesheetLine" valueField="hoursDuration" value="$.hoursDuration" />
		  		<line metaField="unit" metaModel="InvoiceLine"  filter="self.name = 'Hour'"/>
		  	</subLines>
	  	</line>
  	</lines>	
  </action-builder>
  
  <action-builder name="action-timesheet-line-invert-to-invoice"
	isJson="false" 
  	typeSelect="1"
  	appBuilder="PRD" 
  	model="com.axelor.apps.hr.db.Timesheet">
  	<lines>
	  	<line metaField="timesheetLineList" metaModel="Timesheet"  value="$.timesheetLineList" valueModel="Timesheet" valueField="timesheetLineList">
	  		<subLines>
	  			<line metaField="toInvoice" metaModel="TimesheetLine"  value="!$.toInvoice" valueModel="TimesheetLine" valueField="toInvoice" />
	  		</subLines>
	  	</line>
  	</lines>
  </action-builder>
  
  <action-builder name="action-create-product-order-from-category"
  	isJson="true" 
  	typeSelect="0" 
  	appBuilder="PRD"
  	model="ProductCategory"
  	targetModel="ProductOrder">
  	<lines>
	  	<line jsonField="customer" jsonModel="ProductOrder"  filter="self.name = 'Axelor'" />
	  	<line jsonField="status" jsonModel="ProductOrder" value="1" />
	  	<line jsonField="total" jsonModel="ProductOrder"  value="$.products.sum($.price)" />
	  	<line jsonField="lines" jsonModel="ProductOrder"  value="$.products" valueJsonModel="ProductCategory" valueJsonField="products">
	  		<subLines>
	  			<line jsonField="product" jsonModel="ProductOrderLine"  value="$" />
	  			<line jsonField="price" jsonModel="ProductOrderLine"  value="$.price" valueJsonModel="Product" valueJsonField="price" />
	  			<line jsonField="qty" jsonModel="ProductOrderLine"  value="1" />
	  			<line jsonField="total" jsonModel="ProductOrderLine"  value="$.price" valueJsonModel="Product" valueJsonField="price" />
	  		</subLines>
	  	</line>
	</lines>
  </action-builder>
  
  <action-builder name="action-product-order-line-update-total"
  	isJson="true" 
  	typeSelect="1" 
  	appBuilder="PRD"
  	model="ProductOrderLine"
  	targetModel="ProductOrderLine">
  	<lines>
	  	<line jsonField="total" jsonModel="ProductOrderLine"  value="$.price*$.qty" />
	</lines>
  </action-builder>
  
  <action-builder name="action-product-order-line-get-product-details"
  	isJson="true" 
  	typeSelect="1"
  	appBuilder="PRD" 
  	model="ProductOrderLine"
  	targetModel="ProductOrderLine">
  	<lines>
	  	<line jsonField="price" jsonModel="ProductOrderLine" valueJson="Product" valueJsonModel="ProductOrderLine" valueJsonField="product" value="$.product.price" />
	</lines>
  </action-builder>
  
  <action-builder name="action-product-order-update-total"
  	isJson="true" 
  	typeSelect="1" 
  	appBuilder="PRD"
  	model="ProductOrder"
  	targetModel="ProductOrder">
  	<lines>
	  	<line jsonField="total" jsonModel="ProductOrder" valueJson="Product" valueJsonModel="ProductOrder"  valueJsonField="lines" value="$.lines.sum($.total)" />
	</lines>
  </action-builder>
  
</action-builders>
