As Odoo is a comprehensive business management software suite, the Calendar view is a powerful tool used to visualize and manage events, tasks, meetings, deadlines and other time-sensitive activities across various modules such as CRM, Project management, HR modules and more.
In this slide, we can just go through the the steps of creating a calendar view for a module in Odoo 17.
2. Introduction
Enterprise
As Odoo is a comprehensive business management software
suite, the Calendar view is a powerful tool used to visualize
and manage events, tasks, meetings, deadlines and other
time-sensitive activities across various modules such as CRM,
Project management, HR modules and more.
In this slide, we can just go through the the steps of creating a
calendar view for a module in Odoo 17.
3. Enterprise
First, lets create a module, here for example
hospital_management. Lets create a simple model which
stores data of the patients visited. And just define some basic
fields, menus, tree view, form view for the model.
Create some records as for example
4. Enterprise
Creating the Calendar view
Under the ‘views’ directory, we’ve defined an xml file where all
the views are defined. Create a calendar view for the model
using the <calendar> tag in the same file.
5. Enterprise
First, add the calendar view also in the view_mode of the action
for the model.
<record id="action_view_patient_card"
model="ir.actions.act_window">
<field name="name">Patient Card</field>
<field name="res_model">patient.details</field>
<field
name="view_mode">tree,form,calendar</field>
</record>
6. Enterprise
Lets check the xml code we’ve created for the calendar view
<!-- PATIENT DETAILS CALENDAR VIEW →
<record id="patient_details_view_calendar"
model="ir.ui.view">
<field name="name">patient.details.view.calendar</field>
<field name="model">patient.details</field>
<field name="arch" type="xml">
<calendar string="Patients List"
date_start="consult_start_date"
date_stop="consult_end_date"
event_open_popup="form"
mode="month"
color="patient_name_id">
<field name="patient_id"/>
<field name="patient_name_id"
avatar_field="image_1920"/>
<field name="create_date"/>
</calendar>
</field>
</record>
7. Enterprise
Here, there are some attributes used for the calendar
view. Let’s check, for what each of them are used.
● date_start : Name of the field holding the start date for
the calendar event. If we provide this, Odoo will take the
value of this field’s value as the starting date. Datetime
fields are given here.
● date_end: Ending date of the calendar event
● event_open_popup: If set to true, the calendar view will
open events (or records) in a FormViewDialog. Otherwise,
it will open in a new form (do_action)
● mode: Specifies the default mode of displaying the
calendar data. Possible values are year, month, week and
day.
8. Enterprise
● color : To show the records in different color based on a
particular field. That field name can be given as the value
here. It’ll be shown as checkboxes on the sidebar of the
window.
● string: The text string to display.
● Along with these, form_view_id, quick_create, create,
delete, etc can also be used as attributes.
10. Enterprise
On clicking on any of the grid, a popup window will open
These marked fields are those which we’ve added inside the
calendar view using <field> tag
11. For More Info.
Check our company website for related
blogs and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com