<?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 model="com.axelor.apps.account.db.Notification" title="Notifications"
		name="notification-grid" orderBy="-paymentDate,-subrogationRelease">
		<field name="factorPartner" />
		<field name="paymentDate" />
		<field name="subrogationRelease" width="120"/>
		<field name="statusSelect" />
	</grid>

	<form model="com.axelor.apps.account.db.Notification" title="Notification"
		name="notification-form" onNew="action-notification-onnew">

		<panel name="mainPanel" readonlyIf="statusSelect > 1">
			<field name="statusSelect" widget="NavSelect" colSpan="12" />
			<field name="company" onChange="action-account-record-notification-company-onchange" required="true" canEdit="false"/>
			<field name="factorPartner" readonly="true"/>
			<field name="paymentDate" />
			<field name="subrogationRelease" canEdit="false"
				domain="self.company = :company AND self.statusSelect = 3"
				onChange="action-notification-subrogation-release-onchange" />
			<panel-related name="notificationItemListPanel" field="notificationItemList" grid-view="notification-item-grid"
				form-view="notification-item-form" colSpan="12" editable="true" canRemove="false" />
		</panel>

		<panel sidebar="true" name="actionsPanel">
			<button name="validateBtn" title="Validate"
				onClick="save,action-notification-validate" hideIf="statusSelect > 1" />
			<button name="displayMoveLines" title="See Move Lines" onClick="action-notification-display-move-lines-view" showIf="statusSelect == 2"/>
		</panel>
	</form>

	<action-record name="action-notification-onnew"
		model="com.axelor.apps.account.db.Notification">
		<field name="company" expr="eval: __user__.activeCompany" />
		<field name="factorPartner" expr="eval: __user__.activeCompany?.accountConfig?.factorPartner" />
		<field name="paymentDate" expr="eval: __date__" />
	</action-record>
	
	<action-record name="action-account-record-notification-company-onchange" model="com.axelor.apps.account.db.Notification">
		<field name="subrogationRelease" expr="eval: null" />
		<field name="notificationItemList" expr="eval: null" />
		<field name="factorPartner" expr="eval: company?.accountConfig?.factorPartner"/>
	</action-record>

	<action-method name="action-notification-subrogation-release-onchange">
		<call class="com.axelor.apps.account.web.NotificationController"
			method="populateNotificationItemList" />
	</action-method>

	<action-method name="action-notification-validate">
		<call class="com.axelor.apps.account.web.NotificationController"
			method="validate" />
	</action-method>
	
	<action-method name="action-notification-display-move-lines-view">
		<call class="com.axelor.apps.account.web.NotificationController"
			method="displayMoveLines" />
	</action-method>

</object-views>
