Home Blog How to Create a Mail Activity Easily
How to Create a Mail Activity Easily

How To Create a Mail Activity Easily

One of the features of Odoo platform that we have found extremely valuable in improving our communication, collaboration and organization is the introduction of mail activities. In today's changing business environment, it is vital to have communication and task management in order to succeed. 

We are all aware of the difficulties that come with managing emails, tasks and deadlines at the time. This is where Odoo’s mail activities come in as a solution, for simplifying our workflows and increasing productivity.

But if we talk through a developer’s perspective, in their initial days of development, major task for them is to create a mail activity and for that they look over the base code and various platforms to know how to create a mail activity. 

In my initial days i found that there were many solutions, however, they are complex and does not provide clear understanding about what fields are needed to provide a value or what model do we need to inherit.

And to simplify that process for you, I have come up with the following solution:


To create a mail activity we would have to start from scratch. And the scratch is- https://models.py/ file. Yes you read right! You have to create https://models.py/ file , where you need to inherit two models as shown below.

​_inherit = ['mail.thread', 'https://mail.activity.mixin/'] 

'Mail.thread' - This model is used to create chatter in Odoo and will also help us in creating the mail activity.

'Mail.activity.mixin' - This model is essentially needed to create a mail activity. It is also mandatory to inherit this.


Now we’ll move to the next part which is to create the mail activity with the help code,

Step by step, i’ll explain what i personally do:

I create an env, then the mention field which is mandatory to create a mail.activity,

First- activity_type_id: It is the field where you mention what is the type of created activity is, and you can get the value in the same manner for this field as i provided above

Second- date_deadline: it's up to you, what is the requirement for that particular moment, for example, i’ll put in today's date but you can do it in a different manner.

Third- User_id: first let us understand what is the role of this field- this field send our created activity mail to the user id. So whom you want to send mail activity to, you will get in this field.

Fourth- res_model_id: Whenever you just read about this res, one question always strikes in your mind- why is res mentioned in the default code?

Well, if you understand res you understand that where the res is mentioned, it means the table or the data you want to show, initially in my training days, I was also confused regarding it but after research and working on the code- I got my answer and hope you also understand that res means “to show” so res_model_id means the model whose whose form you want to send in mail activity.

And to get the value, let me show you, kindly remember to do it in the same manner.

And the last is res_id: This is a mandatory field which requires the current form id although in most of the cases the parameter takes 'self.id' as the value

We hope that our blog provides you with some clarity and better understanding, we hope you learn from it and keep growing.

  Subscribe our Newsletter for Odoo tips, technical insights, and more!

If you find our content useful, please don’t forget to visit our website. You can also find our in-house developed add-on Odoo modules on our website or on the Odoo App Store!

Get In Touch with Us

Leave a Comment

Your email address will not be published.

Your comment is under review by our moderation team.