<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
    
        <!-- Email Template Preview -->
        <record model="ir.ui.view" id="email_template_preview_form">
            <field name="name">email_template.preview.form</field>
            <field name="model">email_template.preview</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Email Preview">
                    <group col="4" colspan="4">
                        <field name="rel_model" />
                        <field name="rel_model_ref" on_change="on_change_ref(rel_model_ref, context)"/>
                    </group>
                    <group col="8" colspan="4">
                        <field name="to" />
                        <field name="cc" />
                        <field name="bcc" />
                        <field name="reply_to" />
                        <field name="message_id" attrs="{'invisible':[('message_id','=',False)]}" groups="base.group_extended"/>
                        <field name="subject" colspan="8"/>
                    </group>
                    <group col="4" colspan="4">
                        <separator string= "Body(Text)" colspan="2"/>   
                        <separator string= "Body(Html)" colspan="2"/>
                        <newline/>
                        <field name="body_text" nolabel="1" colspan="2"/>
                        <field name="body_html" nolabel="1" colspan="2"/>
                    </group>
                    <field name="report" colspan="2"/>
                    <button icon="gtk-ok" special="cancel" string="OK" colspan="1"/>
                </form>
            </field>
        </record>
        
        <record id="wizard_email_template_preview" model="ir.actions.act_window">
            <field name="name">Template Preview</field>
            <field name="res_model">email_template.preview</field>
            <field name="src_model">email_template.preview</field>
            <field name="type">ir.actions.act_window</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="auto_refresh" eval="1" />
            <field name="target">new</field>
            <field name="context">{'template_id':active_id}</field>
        </record>
        <!--EMail client Form view  -->

        <record model="ir.ui.view" id="email_template_form">
            <field name="name">email.template.form</field>
            <field name="model">email.template</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Email Templates">
                    <field name="name" />
                    <field name="object_name" required="1"
                        on_change="change_model(object_name)" />
                    <field name="model_int_name" invisible="1" />
                    <notebook colspan="4">
                        <page string="Mail Details">
                            <group col="2" colspan="2">
                                <separator string="Addresses" colspan="2"/>
                                <field name="from_account" required="1"/>
                                <field name="def_to" required="1"/>
                                <field name="def_cc"/>
                                <field name="def_bcc"/>
                                <field name="reply_to"/>
                            </group>
                            <group col="2" colspan="2">
                                <separator string="Options" colspan="2"/>
                                <field name="lang" colspan="4" />
                                <field name="use_sign" colspan="4" />
                                <field name="track_campaign_item" colspan="4"/>
                            </group>
                            <group col="2" colspan="2">
                                <separator colspan="2" string="Email Content  " />
                                <field name="def_subject" colspan="4" required="1" />
                                <notebook>
                                    <page string="Body (Text)">
                                        <field name="def_body_text" colspan="4" nolabel="1" />
                                    </page>
                                    <page string="Body (Raw HTML)">
                                        <field name="def_body_html" colspan="4" nolabel="1" />
                                        <label string="Note: This is Raw HTML." colspan="4" />
                                    </page>
                                </notebook>
                            </group>
                            <group col="4" colspan="2">
                                <separator colspan="4" string="Expression Builder" />
                                <field name="template_language"
                                    on_change="onchange_null_value(model_object_field,sub_model_object_field,null_value,template_language,context)" />
                                <notebook>
                                    <page string="Insert Simple Field">

                                        <field name="model_object_field"
                                            domain="[('model_id','=',object_name),('ttype','!=','one2many'),('ttype','!=','many2many')]"
                                            on_change="onchange_model_object_field(model_object_field, template_language,context)"
                                            colspan="4" />
                                        <field name="sub_object" readonly="1" colspan="4" />
                                        <field name="sub_model_object_field"
                                            domain="[('model_id','=',sub_object),('ttype','!=','one2many'),('ttype','!=','many2many')]"
                                            colspan="4"
                                            attrs="{'readonly':[('sub_object','=',False)],'required':[('sub_object','!=',False)]}"
                                            on_change="onchange_sub_model_object_field(model_object_field,sub_model_object_field,template_language,context)" />
                                        <field name="null_value" colspan="4"
                                            on_change="onchange_null_value(model_object_field,sub_model_object_field,null_value,template_language,context)" />
                                        <field name="copyvalue" colspan="4" />
                                    </page>
                                </notebook>
                                <button name="%(wizard_email_template_preview)d" string="Preview Template"
                                    type="action" colspan="4" target="new" icon="gtk-zoom-fit"/>
                            </group>
                        </page>
                        <page string="Advanced">
                            <group colspan="2" col="2">
                                <group colspan="2" col="2">
                                    <separator string="Actions" colspan="2"/>
                                    <button name="create_action" string="Create Action" type="object" icon="gtk-execute"  colspan="2" attrs="{'invisible':[('ref_ir_act_window','!=',False), ('ref_ir_value','!=',False)]}"/>
                                    <field name="ref_ir_act_window"/>
                                    <field name="ref_ir_value"/>
                                    <button name="delete_action" string="Delete Action" type="object" icon="gtk-delete" colspan="2" attrs="{'invisible':[('ref_ir_act_window','=',False), ('ref_ir_value','=',False)]}"/>
                                </group>
                                <group colspan="2" col="2">
                                    <separator string="Advanced Options" colspan="2"/>
                                    <field name="message_id"/>
                                </group>
                            </group>
                            <group colspan="2" col="2">
                                <separator string="Attachments" colspan="2"/>
                                <notebook>
                                    <page string="Existing files">
                                        <field name="attachment_ids" colspan="4" nolabel="1" height="350"/>
                                    </page>
                                    <page string="Report">
                                        <field name="report_template" colspan="4"
                                            domain="[('model','=',model_int_name)]" />
                                        <field name="file_name" colspan="4" />
                                    </page>
                                </notebook>
                            </group>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="email_template_tree">
            <field name="name">email.template.tree</field>
            <field name="model">email.template</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Email Templates">
                    <field name="name"/>
                    <field name="from_account"/>
                    <field name="object_name"/>
                    <field name="def_to"/>
                    <field name="def_cc"/>
                    <field name="def_bcc"/>
                    <field name="def_subject"/>
                    <field name="use_sign"/>
                    <field name="file_name"/>
                    <button name="%(wizard_email_template_preview)d" string="Preview Template"
                            type="action" target="new" icon="gtk-zoom-fit"/>
                </tree>
            </field>
        </record>

        <record id="view_email_template_search" model="ir.ui.view">
           <field name="name">email.template.search</field>
           <field name="model">email.template</field>
           <field name="type">search</field>
           <field name="arch" type="xml">
               <search string="Templates">
                    <group col="13" colspan="4">
                        <field name="name" select="1"/>
                        <field name="object_name" select="1"/>
                        <field name="def_to" select="1"/>
                        <separator orientation="vertical"/>
                        <field name="lang" select="1"/>
                        <field name="def_subject" select="1"/>
                        <field name="file_name" select="1"/>
                    </group>
                    <newline/>
                    <group expand="0" string="Group by..." colspan="4" col="10">
                        <filter string="Account" domain="[]" context="{'group_by':'from_account'}" icon="terp-folder-orange"/>
                        <separator orientation="vertical"/>
                        <filter string="Resource" domain="[]" context="{'group_by':'object_name'}" icon="terp-accessories-archiver"/>
                    </group>
               </search>
           </field>
        </record>

        <record model="ir.actions.act_window" id="action_email_template_tree_all">
            <field name="name">Email Templates</field>
            <field name="res_model">email.template</field>
            <field name="view_type">form</field>
            <field name="view_mode">form,tree</field>
            <field name="view_id" ref="email_template_tree" />
            <field name="search_view_id" ref="view_email_template_search"/>
        </record>

        <menuitem name="Email Templates" id="menu_email_template_all"
            parent="menu_email_template" action="action_email_template_tree_all" />

        <!-- Email Template menu in Tools -->
        <menuitem name="Email Templates" id="menu_email_template_all_tools"
            parent="menu_email_template_config_tools" action="action_email_template_tree_all" />
    </data>
</openerp>





