How to Create Activity View in Odoo

Abid Patel
04-Oct-2024 Updated : 04-Oct-2024

Learn how to create an Activity View in Odoo for efficient mail activity and streamlined Odoo activity management. visit our website free web snippets

How to Create Activity View in Odoo

Odoo is a powerful open-source ERP platform that offers a wide range of features to streamline business operations. One of the useful features available in Odoo is the Activity View. This view allows users to manage activities such as tasks, meetings, and follow-ups efficiently. In this blog post, we will guide you on how to create an Activity View in Odoo, enhancing your productivity and organization.

What is an Activity View in Odoo?

The Activity View in Odoo provides a comprehensive way to visualize and manage tasks and activities associated with records. This view enables users to track their tasks, schedule meetings, and set reminders, ensuring that no important activity is overlooked. It is especially beneficial for sales teams, project managers, and customer service representatives.

Steps to Create an Activity View

To create an Activity View in Odoo, you will need to follow a few straightforward steps. Below is a step-by-step guide to help you through the process.

Step 1: Define the Model

First, you need to define the model for which you want to create the Activity View. You can do this in your custom module by creating a new Python model. Here’s an example:

python

from odoo import models, fields

class MyCustomModel(models.Model):
    _name = 'my.custom.model'
    _description = 'Custom Model for Activities'

    name = fields.Char(string='Name', required=True)
    activity_ids = fields.One2many('mail.activity', 'res_id', string='Activities')

In this code snippet, we define a custom model my.custom.model that has a one-to-many relationship with the mail.activity model, which stores the activities associated with this record.

Step 2: Create the XML View

Next, you need to create the XML view for your Activity View. This is where you will define how the activities will be displayed in the Odoo interface. Below is an example of how to create the Activity View:

xml

<record id="view_my_custom_model_activity" model="ir.ui.view">
    <field name="name">my.custom.model.activity.view</field>
    <field name="model">my.custom.model</field>
    <field name="arch" type="xml">
        <form string="Activities">
            <sheet>
                <group>
                    <field name="name"/>
                    <field name="activity_ids" widget="activity" />
                </group>
            </sheet>
        </form>
    </field>
</record>

In this XML code, we define a form view for the custom model where we include the activity_ids field with the widget="activity" attribute. This widget automatically integrates the Activity View functionality.

Step 3: Add the View to the Menu

Once you have defined the model and the view, you need to add the Activity View to the menu. This will allow users to access it from the Odoo interface. Here’s an example of how to do this:

xml

<record id="action_my_custom_model" model="ir.actions.act_window">
    <field name="name">My Custom Model</field>
    <field name="res_model">my.custom.model</field>
    <field name="view_mode">tree,form</field>
</record>

<menuitem id="menu_my_custom_model" name="My Custom Model" action="action_my_custom_model" sequence="10"/>

This code snippet creates an action that links to the custom model and adds a menu item for users to access it easily.

Step 4: Testing the Activity View

After completing the above steps, it’s essential to test your Activity View. Navigate to the menu item you created, and you should see the Activity View where you can add and manage activities associated with your records.

Conclusion

Creating an Activity View in Odoo is a straightforward process that can significantly enhance your task management capabilities. By following the steps outlined in this blog, you can streamline your operations and ensure that you never miss an important activity. For more information on Odoo customization and features, visit the free web snippets or explore Odoo Studio for additional customization options.

Make a Comment

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