<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>

        <record model="ir.ui.view" id="view_server_action_form_template">
            <field name="name">ir.actions.server.form</field>
            <field name="model">ir.actions.server</field>
            <field name="inherit_id" ref="base.view_server_action_form"/>
            <field name="arch" type="xml">
                <xpath expr="//form" position="inside">
                    <chatter/>
                </xpath>
                <xpath expr="//t[@name='action_content']//notebook" position="before">
                    <!-- Create next activity -->
                    <div class="d-flex flex-column" invisible="state != 'next_activity'">
                        <label for="activity_plan_id" invisible="not has_activity_plans"/>
                        <field name="activity_plan_id"
                            widget="selection_badge"
                            options="{'size': 'sm'}"
                            required="not activity_type_id and state == 'next_activity'"
                            invisible="not has_activity_plans"/>
                        <label for="activity_type_id"/>
                        <field name="activity_type_id"
                            widget="selection_badge_icons"
                            options="{'size': 'sm', 'related_icon_field': 'icon'}"
                            required="not activity_plan_id and state == 'next_activity'"/>
                    </div>
                    <group invisible="state != 'next_activity'">
                        <group colspan="2" invisible="not activity_type_id">
                            <label for="activity_summary" class="o_form_label fs-3"/>
                            <field name="activity_summary"
                                nolabel="1"
                                placeholder="e.g. Discuss proposal"
                                class="fs-3 w-100"/>
                        </group>
                        <group>
                            <label for="activity_date_deadline_range"/>
                            <div class="d-flex flex-row gap-2">
                                <field name="activity_date_deadline_range" class="oe_inline o_input_3ch"/>
                                <field name="activity_date_deadline_range_type" class="oe_inline" required="state == 'next_activity' and activity_date_deadline_range &gt; 0"/>
                            </div>
                            <label for="activity_user_type" string="Assign to" invisible="state != 'next_activity' or (not activity_type_id and not activity_plan_has_user_on_demand)"/>
                            <div class="d-flex flex-row gap-2" invisible="state != 'next_activity' or (not activity_type_id and not activity_plan_has_user_on_demand)">
                                <field name="activity_user_type"
                                    required="state == 'next_activity' and (activity_type_id or activity_plan_has_user_on_demand)"/>
                                <field name="activity_user_field_name"
                                    invisible="activity_user_type != 'generic'"
                                    widget="field_selector"
                                    options="{'model': 'model_name'}"
                                    required="state == 'next_activity' and activity_user_type == 'generic'"/>
                                <field name="activity_user_id"
                                    invisible="activity_user_type != 'specific'"
                                    placeholder="Choose a user..."
                                    widget="many2one_avatar_user"
                                    required="state == 'next_activity' and activity_user_type == 'specific' "/>
                            </div>
                        </group>
                        <group colspan="2" invisible="not activity_type_id">
                            <field name="activity_note"
                                nolabel="1"
                                class="oe-inline oe-bordered-editor embedded-editor-height-4"
                                placeholder="Log a note..."/>
                        </group>
                    </group>
                    <!-- Add/Remove Followers -->
                    <group invisible="state not in ['followers', 'remove_followers']">
                        <group>
                            <field name="followers_type"
                                required="state in ['followers', 'remove_followers']"/>
                            <field name="partner_ids" string="Followers to add" widget="many2many_tags"
                                placeholder="Choose a contact..."
                                invisible="state != 'followers' or followers_type != 'specific'"
                                required="state == 'followers' and followers_type == 'specific'"/>
                            <field name="partner_ids" string="Followers to remove" widget="many2many_tags"
                                placeholder="Choose a contact..."
                                invisible="state != 'remove_followers' or followers_type != 'specific'"
                                required="state == 'remove_followers' and followers_type == 'specific'"/>
                            <field name="followers_partner_field_name"
                                widget="field_selector" options="{'model': 'model_name'}"
                                invisible="followers_type != 'generic'"
                                required="state in ['followers', 'remove_followers'] and followers_type == 'generic'"/>
                        </group>
                    </group>
                    <!-- Send Email -->
                    <group invisible="state != 'mail_post'">
                        <group>
                            <field name="template_id"
                                placeholder="Choose a template..."
                                required="state == 'mail_post'"
                                context="{'default_model': model_name,
                                            'default_use_default_to': True}"/>
                            <label for="mail_post_method"/>
                            <div class="d-flex flex-column">
                                <field name="mail_post_method" required="state == 'mail_post'"/>
                                <div class="text-muted">
                                    <span invisible="mail_post_method != 'email'">
                                        The message will be sent as an email to the recipients of the
                                        template and will not appear in the messaging history.
                                    </span>
                                    <span invisible="mail_post_method != 'note'">
                                        The message will be posted as an internal note visible to internal
                                        users in the messaging history.
                                    </span>
                                    <span invisible="mail_post_method != 'comment'">
                                        The message will be posted as a message on the record,
                                        notifying all followers. It will appear in the messaging history.
                                    </span>
                                </div>
                            </div>
                            <field name="mail_post_autofollow" invisible="1"/>
                        </group>
                    </group>
                </xpath>
            </field>
        </record>

    </data>
</odoo>
