<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="marketing_activity_view_form" model="ir.ui.view">
        <field name="name">marketing.activity.view.form</field>
        <field name="model">marketing.activity</field>
        <field name="arch" type="xml">
            <form string="Activity">
                <sheet>
                    <div class="oe_title">
                        <label for="name" class="oe_edit_only" string="Name" />
                        <h1><field name="name" required="1" placeholder="e.g. eCommerce Offers" /></h1>
                    </div>
                    <group>
                        <group>
                            <field name="activity_type" widget="radio" options="{'horizontal': true}" />
                            <div class="o_td_label">
                                <label for="mass_mailing_id" string="Mail Template" attrs="{'invisible': [('activity_type', '!=', 'email')]}"/>
                            </div>
                            <div>
                                <field name="mass_mailing_id"
                                    domain="[('mailing_model_id', '=', model_id), ('use_in_odex25_marketing_automation', '=', True), ('mailing_type', '=', mass_mailing_id_mailing_type)]"
                                    context="{
                                        'default_state': 'done',
                                        'default_mailing_model_id': model_id,
                                        'default_use_in_odex25_marketing_automation': True,
                                        'default_campaign_id': utm_campaign_id,
                                        'default_mailing_type': mass_mailing_id_mailing_type,
                                        'form_view_ref': 'odex25_marketing_automation.mailing_mailing_view_form_marketing_activity'}"
                                    attrs="{
                                        'required': [('activity_type', '=', 'email')],
                                        'invisible': [('activity_type', '!=', 'email')]}"
                                    options="{'no_quick_create': True}"/>
                            </div>
                            <field name="server_action_id" domain="[('model_id', '=', model_id)]" attrs="{'required': [('activity_type', '=', 'action')], 'invisible': [('activity_type', '!=', 'action')]}"
                                    context="{'default_model_id': model_id,
                                            'form_view_ref': 'odex25_marketing_automation.ir_actions_server_view_form_odex25_marketing_automation'}" />
                            <field name="statistics_graph_data" invisible="1" />
                            <field name="mass_mailing_id_mailing_type" invisible="1" />
                        </group>
                        <group>
                            <label for="interval_number" string="Trigger"/>
                            <div class="container">
                                <div class="row">
                                    <field name="interval_number" nolabel="1" class="col-2 px-0"/>
                                    <field name="interval_type" nolabel="1" class="col-10"/>
                                </div>
                                <div class="row">
                                    <span class="col-2 px-0 pt-1">after</span>
                                    <field name="trigger_type" class="col-10 pt-1 pr-1"/>
                                </div>
                            </div>
                            <label for="parent_id" attrs="{'invisible': [('trigger_type', '=', 'begin')]}"/>
                            <div>
                                <field name="allowed_parent_ids" invisible="1"/>
                                <field name="parent_id"
                                    domain="[('id', 'in', allowed_parent_ids)]"
                                    attrs="{'required': [('trigger_type', '!=', 'begin')], 'invisible': [('trigger_type', '=', 'begin')]}"
                                    options="{'no_create_edit': True, 'no_create': True}"/>
                            </div>
                            <span class="o_form_label" invisible="1">Warning</span>
                            <div>
                                <small class="oe_edit_only text-muted" attrs="{'invisible': [('trigger_type', '=', 'begin')]}">(save the campaign to make its activities selectable)</small>
                            </div>
                            <label for="validity_duration" string="Expiry Duration"/>
                            <div>
                                <field name="validity_duration"/>
                            </div>
                            <label for="validity_duration_number" string="Cancel after" attrs="{'invisible': [('validity_duration', '=', False)]}"/>
                            <div attrs="{'invisible': [('validity_duration', '=', False)]}" class="container">
                                <div class="row">
                                    <field name="validity_duration_number" nolabel="1" class="col-2 px-0"/>
                                    <field name="validity_duration_type" nolabel="1" class="col-10"/>
                                </div>
                            </div>
                            <field name="model_id" invisible="1"/>
                            <field name="model_name" invisible="1"/>
                            <field name="utm_campaign_id" invisible="1"/>
                        </group>
                    </group>
                    <group string="Domain">
                        <field name="activity_domain" widget="domain" options="{'in_dialog': True, 'model': 'model_name'}" />
                        <field name="domain" widget="domain" options="{'in_dialog': True, 'model': 'model_name'}" />
                    </group>
                </sheet>
            </form>
        </field>
    </record>
</odoo>
