I want to customize the name of the event that i see on the calendare view:
I tried to do some changes but i wasn't able to set the name of the event in the way i want to.
I want to display the name and the location separated by a "-"
the name of the "location" previously mentioned is: "x_studio_stringa_mezzi"
with the changes that i made i was able to change elements on the description of the event but not on the title.
I'm working on the 18 version of odoo and i'm trying to edit files (both py and xml) whit filezilla.
I did this:
Override get_event_title to return the combined string.
from odoo import models
class CalendarEvent (models.Model):
_inherit = 'calendar.event' # or your custom model
def get_event_title ( self, meeting ):
name = meeting.get( 'name' , '' )
location = meeting.get( 'location' , '' )
if location:
return f" {name} - {location} "
return name
This method is called by Odoo's JS calendar renderer to determine what to show in the calendar slot.
Ensure location is in the calendar view fields
Odoo Calendar fetches fields defined in the calendar view XML:
<field name = "calendar_view">
<calendar string = "Calendar" date_start = "start" date_stop = "stop" color = "user_id">
<field name = "name"/>
<field name = "location"/>
</calendar>
</field>
Make sure location is included, or it won’t be available in meeting.get(...) during title formatting.
Thanks for helping me