The activity view is one of the useful views that support Odoo and allows the user to manage all business operations. We get information about activities related to our records in this view, so users can easily identify the scheduled activities.
First, we must add "mail" to the dependencies - 'depends': ['mail'],
We need to inherit the mail.thread and mail.activity.mixin models after adding dependencies to the manifest.
Model for an example
class VisaApplication(models.Model):
_name = "visa.application"
_inherit = ['mail.thread', 'mail.activity.mixin']
name = fields.Char(string='Name', required=True)
demo_field1 = fields.Many2one('res.users', 'Author', required=True)
no = fields.Char('Sl No', required=True)
Action definition
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="record_action" model="ir.actions.act_window">
<field name="name">Visa Application</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">visa.application</field>
<field name="view_mode">tree,form,activity</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new record!
</p>
</field>
</record>
In addition, the activity view is defined.
<record id="visa_application_activity" model="ir.ui.view">
<field name="name">visa.application.activity</field>
<field name="model">visa.application</field>
<field name="arch" type="xml">
<activity string="Applicants">
<templates>
<div t-name="activity-box">
<div>
<field name="name"/>
</div>
</div>
</templates>
</activity>
</field>
</record>
</odoo>
The result will be: