Target Inline In Odoo

Abid Patel
14-Oct-2024 Updated : 14-Oct-2024

Learn how to use the target inline feature in Odoo to display content directly within the parent view, enhancing user experience and workflow efficiency.

Target Inline In Odoo

Odoo offers a versatile framework that allows developers to customize views and actions for a better user experience. One of the customization options available is using the target="inline" attribute in Odoo. This is particularly useful when you want to display forms or views directly inside the current screen without opening them in a new window or as a pop-up. In this blog, we’ll explore how to implement the Target Inline feature in Odoo.

What is Target Inline in Odoo?

The target="inline" attribute in Odoo allows a form or view to be displayed within the current interface rather than in a pop-up or new window. This option is often used when you want to keep the user on the same page while allowing them to edit or view related records without navigating away from their current task. It improves user experience by providing a more seamless and fluid workflow.

How to Use Target Inline in Odoo

Let’s look at an example where we define an action with the target set to inline. This example shows how the configuration is done within an XML file:

Path
<record id="action_sale_config_settings" model="ir.actions.act_window">
    <field name="name">Settings</field>
    <field name="res_model">res.config.settings</field>
    <field name="view_id" ref="res_config_settings_view_form"/>
    <field name="view_mode">form</field>
    <field name="target">inline</field>
    <field name="context">{'module' : 'sale_management', 'bin_size': False}</field>
</record>

Explanation of the Example

In the above XML code:

  • id: Defines the unique ID for the action, in this case, action_sale_config_settings.
  • name: The name of the action, which will appear in the UI as Settings.
  • res_model: Refers to the model that the action is linked to, here it is res.config.settings.
  • view_id: The view that will be displayed, linked to res_config_settings_view_form.
  • view_mode: This field specifies that the view will be displayed in form mode.
  • target: Setting the target to inline ensures that the form is displayed within the existing window rather than opening in a pop-up or new window.
  • context: This field provides additional context, such as the specific module (sale_management) and configuration settings.

Why Use Target Inline in Odoo?

By using the target="inline" attribute, you ensure that users can interact with related views or forms without leaving the page they’re working on. This method creates a more streamlined and efficient workflow, which is especially important for processes involving multiple steps or related records. It also reduces the need for pop-ups and page reloads, keeping the user focused on their current task.

For more detailed information on Odoo menu customization, refer to the Free web snippets.

Make a Comment

Your email address will not be published. Required fields are marked *