<?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="project-invoicing-assistant-batch-grid" title="Project invoicing assistant batches" model="com.axelor.apps.businessproject.db.ProjectInvoicingAssistantBatch">
		<field name="actionSelect" />
		<field name="code" x-bind="{{code|unaccent|uppercase}}" />
		<field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="createdOn"/>
		<field name="createdBy" form-view="user-form" grid-view="user-grid"/>
  	</grid>
  	
  	<form name="project-invoicing-assistant-batch-form" title="Project invoicing assistant batch" model="com.axelor.apps.businessproject.db.ProjectInvoicingAssistantBatch"  
    onNew="action-project-invoicing-assistant-batch-record-on-new">
    	<panel name="mainPanel">
		    <field name="actionSelect" onChange="action-base-batch-attrs-action-select"/>
		    <field name="code" x-bind="{{code|unaccent|uppercase}}" onChange="action-base-batch-condition-check-unique-code"/>
		    <field name="company" widget="SuggestBox" form-view="company-form" grid-view="company-grid"/>
		</panel>
    	<panel name="informationPanel" title="Information">
			<field name="createdOn" title="Created on"/>
			<field name="createdBy" title="Created by" form-view="user-form" grid-view="user-grid"/>
			<field name="description" showTitle="false" colSpan="12"/>
			<panel-related name="batchListPanel" field="batchList" colSpan="12" form-view="batch-form" grid-view="batch-grid"/>
	    </panel>
  		<panel name="actionPanel" sidebar="true">
  			<button name="updateTaskBtn" title="Update tasks" onClick="save,action-project-invoicing-assistant-batch-method-update-task" showIf="actionSelect == 1"/>
  			<button name="generateInvoicingProjectBtn" title="Generate invoicing projects" onClick="save,action-project-invoicing-assistant-batch-method-generate-inv-project" showIf="actionSelect == 2"/>
  		</panel>
    </form>

    <action-record name="action-project-invoicing-assistant-batch-record-on-new" model="com.axelor.apps.businessproject.db.ProjectInvoicingAssistantBatch">
		<field name="createdOn" expr="eval:__config__.app.getTodayDate()"/>
		<field name="createdBy" expr="eval:__user__"/>
		<field name="company"  expr="eval:__user__.activeCompany" if="__user__.activeCompany != null"/>
    	<field name="company"  expr="eval:__repo__(Company).all().fetchOne()" if="__user__.activeCompany == null &amp;&amp; __repo__(Company).all().fetch().size == 1"/>
	</action-record>
	
	<action-method name="action-project-invoicing-assistant-batch-method-update-task">
		<call class="com.axelor.apps.businessproject.web.ProjectInvoicingAssistantBatchController" method="actionUpdateTask"/>
	</action-method>
	
	<action-method name="action-project-invoicing-assistant-batch-method-show-task">
		<call class="com.axelor.apps.businessproject.web.ProjectInvoicingAssistantBatchController" method="showUpdatedTask"/>
	</action-method>
	
	<action-method name="action-project-invoicing-assistant-batch-method-show-timesheet-line">
		<call class="com.axelor.apps.businessproject.web.ProjectInvoicingAssistantBatchController" method="showUpdatedTimesheetLine"/>
	</action-method>
	
	<action-method name="action-project-invoicing-assistant-batch-method-generate-inv-project">
		<call class="com.axelor.apps.businessproject.web.ProjectInvoicingAssistantBatchController" method="actionGenerateInvoicingProject"/>
	</action-method>
	
	<action-method name="action-project-invoicing-assistant-batch-method-show-inv-project">
		<call class="com.axelor.apps.businessproject.web.ProjectInvoicingAssistantBatchController" method="showGeneratedInvoicingProject"/>
	</action-method>
	
</object-views>