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


    <record id="sql_export_mail_view_form" model="ir.ui.view">
        <field name="model">sql.export</field>
        <field name="inherit_id" ref="sql_export.sql_export_view_form" />
        <field name="arch" type="xml">
            <button name="export_sql_query" position="after">
                <button name="create_cron" string="Create Cron" type="object" groups="base.group_system"
                        attrs="{'invisible': ['|', ('state', '=', 'draft'), ('mail_user_ids', '=', [(6, False, [])])]}"/>
            </button>
            <field name="copy_options" position="after">
                <field name="mail_condition" attrs="{'invisible': [('cron_ids', '=', [(6, False, [])])]}"/>
            </field>
            <group name="parameters" position="after">
                <group groups="sql_request_abstract.group_sql_request_user">
                    <group string="Users Notified by e-mail">
                        <field name="mail_user_ids" nolabel="1"/>
                    </group>
                    <group string="Crons" groups="base.group_system">
                        <field name="cron_ids" nolabel="1" domain="[('function', '=', '_run_all_sql_export_for_cron')]"/>
                    </group>
                </group>
            </group>
        </field>
    </record>

</odoo>

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


    <record id="sql_export_mail_view_form" model="ir.ui.view">
        <field name="model">sql.export</field>
        <field name="inherit_id" ref="sql_export.sql_export_view_form" />
        <field name="arch" type="xml">
            <button name="export_sql_query" position="after">
                <button name="create_cron" string="Create Cron" type="object" groups="base.group_system"
                        attrs="{'invisible': ['|', ('state', '=', 'draft'), ('mail_user_ids', '=', [(6, False, [])])]}"/>
            </button>
            <field name="copy_options" position="after">
                <field name="mail_condition" attrs="{'invisible': [('cron_ids', '=', [(6, False, [])])]}"/>
            </field>
            <group name="parameters" position="after">
                <group groups="sql_request_abstract.group_sql_request_user">
                    <group string="Users Notified by e-mail">
                        <field name="mail_user_ids" nolabel="1"/>
                    </group>
                    <group string="Crons" groups="base.group_system">
                        <field name="cron_ids" nolabel="1" domain="[('function', '=', '_run_all_sql_export_for_cron')]" groups="base.group_system"/>
                    </group>
                </group>
            </group>
        </field>
    </record>

</odoo>

Add group on cron field to avoid access error when user does not have the right to read crons.
Add group on cron field to avoid access error when user does not have the right to read crons.
