<?xml version="1.0"?>
<form string="Server Action">
                    <header>
                        <field name="binding_model_id" invisible="1"/>
                        <button name="create_action" string="Create Contextual Action" type="object" class="btn-primary" attrs="{'invisible':[('binding_model_id','!=',False)]}" help="Display an option in the 'More' top-menu in order to run this action."/>
                        <button name="unlink_action" string="Remove Contextual Action" type="object" attrs="{'invisible':[('binding_model_id','=',False)]}" help="Remove 'More' top-menu contextual action related to this action"/>
                        <button name="run" string="Run" type="object" class="btn-primary" attrs="{'invisible':['|', ('model_id', '!=', 23), ('state', '!=', 'code')]}" help="Run this action manually."/>
                    </header>
                    <sheet>
                        <div class="oe_title">
                            <label for="name"/>
                            <h1><field name="name" placeholder="e.g. Update order quantity"/></h1>
                        </div>
                        <group name="action_wrapper">
                            <group name="action_content">
                                <field name="model_id" options="{'no_create': True}"/>
                                <field name="model_name" invisible="1"/>
                            </group>
                            <group>
                                <field name="state"/>
                                <field name="type" invisible="1"/>
                                <field name="crud_model_id" options="{'no_create': True}" attrs="{'invisible': [('state', '!=', 'object_create')], 'required': [('state', '=', 'object_create')]}"/>
                                <field name="crud_model_name" invisible="1"/>
                                <field name="link_field_id" domain="[('model_id', '=', model_id), ('relation', '=', crud_model_name),                                     ('ttype', 'in', ['many2one', 'one2many', 'many2many'])]" options="{'no_create': True}" attrs="{'invisible': [('state', '!=', 'object_create')]}" context="{'default_model_id': model_id, 'default_relation': crud_model_name}"/>
                            </group>
                        </group>
                        <notebook>
                            <page string="Python Code" name="code" attrs="{'invisible': [('state', '!=', 'code')]}">
                                <field name="code" widget="ace" options="{'mode': 'python'}" placeholder="Enter Python code here. Help about Python expression is available in the help tab of this document."/>
                            </page>

                            <page string="Data to Write" name="page_object" attrs="{'invisible':[('state', 'not in', ['object_create', 'object_write'])]}">
                                <p attrs="{'invisible': [('model_id', '!=', False)]}">
                                    Please set the Model to Create before choosing values
                                </p>
                                <field name="fields_lines">
                                     <tree string="Field Mappings" editable="bottom">
                                        <field name="col1" options="{'no_create': True}" domain="['|', ('model_id', '=', parent.crud_model_id), ('model_id', '=', parent.model_id)]"/>
                                        <field name="evaluation_type"/>
                                        <field name="resource_ref" options="{'hide_model': True, 'no_create': True}" attrs="{'readonly': [('evaluation_type', '!=', 'reference')]}"/>
                                        <field name="value" attrs="{'readonly': [('evaluation_type', '=', 'reference')]}" options="{'no_create': True}" force_save="1"/>
                                    </tree>
                                </field>
                            </page>

                            <page name="security" string="Security">
                                <field name="groups_id"/>
                            </page>

                            <page string="Actions" name="actions" attrs="{'invisible': [('state', '!=', 'multi')]}">
                                <p class="oe_grey">
                                    If several child actions return an action, only the last one will be executed.
                                    This may happen when having server actions executing code that returns an action, or server actions returning a client action.
                                </p>
                                <field name="child_ids" domain="[('model_id', '=', model_id)]"/>
                            </page>

                            <page string="Help" name="help_info" attrs="{'invisible': [('state', '!=', 'code')]}">
                                <div style="margin-top: 4px;">
                                    <h3>Help with Python expressions</h3>
                                    <p>Various fields may use Python code or Python expressions. The following variables can be used:</p>
                                    <ul>
                                        <li><code>env</code>: Odoo Environment on which the action is triggered</li>
                                        <li><code>model</code>: Odoo Model of the record on which the action is triggered; is a void recordset</li>
                                        <li><code>record</code>: record on which the action is triggered; may be be void</li>
                                        <li><code>records</code>: recordset of all records on which the action is triggered in multi mode; may be void</li>
                                        <li><code>time</code>, <code>datetime</code>, <code>dateutil</code>, <code>timezone</code>: useful Python libraries</li>
                                        <li><code>log(message, level='info')</code>: logging function to record debug information in <code>ir.logging</code> table</li>
                                        <li><code>UserError</code>: Warning Exception to use with <code>raise</code></li>
                                        <li><code>Command</code>: x2Many commands namespace</li>
                                        <li>To return an action, assign: <code>action = {...}</code></li>
                                    </ul>
                                    <div attrs="{'invisible': [('state', '!=', 'code')]}">
                                        <p>Example of Python code</p>
<code style="white-space: pre-wrap">
partner_name = record.name + '_code' \n
env['res.partner'].create({'name': partner_name})
</code>
                                    </div>
                                </div>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            