<?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">
    
    
    <form name="generate-message-wizard-form"  model="com.axelor.apps.base.db.Wizard" title="Generate message" onNew="action-generate-message-group-on-new">
    	<panel name="mainPanel" >
	      	<field name="_xTemplate" title="Template" widget="SuggestBox" type="MANY_TO_ONE" target="com.axelor.apps.message.db.Template" target-name="name"
				   form-view="template-form" grid-view="template-grid" onSelect="action-method-template-domain"/>
	      	<field name="language" title="Language" widget="SuggestBox" type="MANY_TO_ONE" target="com.axelor.apps.base.db.Language" target-name="name"
				   form-view="language-form" grid-view="language-grid" onChange="action-on-change-language-template"/>
			<spacer name="languageSpacer"/>
	      	<button name="validateBtn" title="Validate" onClick="save, action-generate-message-method-generate-message"/>
      	</panel>
	</form>

	<action-group name="action-generate-message-group-on-new">
		<action name="action-generate-message-record-on-new"/>
		<action name="action-method-template-domain"/>
	</action-group>

	<action-record name="action-generate-message-record-on-new" model="com.axelor.apps.base.db.Wizard">
		<field name="_xTemplate" expr="eval:__repo__(Template).all().filter('self.metaModel.fullName = ?1 and self.isDefault = true and self.isSystem != true',_templateContextModel).fetchOne()"/>
		<field name="language" expr="eval:__repo__(Template).all().filter('self.metaModel.fullName = ?1 and self.isDefault = true and self.isSystem != true',_templateContextModel).fetchOne().getLanguage()"
			   if="__repo__(Template).all().filter('self.metaModel.fullName = ?1 and self.isDefault = true and self.isSystem != true',_templateContextModel).fetchOne() != null"/>
	</action-record>

	<action-method name="action-generate-message-method-generate-message">
    	<call class="com.axelor.apps.message.web.GenerateMessageController" method="generateMessage"/>
    </action-method>

	<action-attrs name="action-on-change-language-template">
		<attribute for="_xTemplate" name="value" expr="eval: null"/>
	</action-attrs>

</object-views>
