La domanda è stata contrassegnata
Hello,
Your computed field approach is correct and is generally the recommended way to determine whether an event should receive special styling.
In Odoo 16, Calendar events are rendered through FullCalendar and OWL components, so simply patching methods like getEventOptions() or eventDataTransform() may not always affect the final DOM output. A cleaner approach is to extend the Calendar renderer/component responsible for event rendering and inject a custom class based on your is_crm_hatched field.
If the requirement is only visual differentiation, using Odoo's native color mechanism is often the simplest and most upgrade-friendly solution. However, if you specifically need the o_event_hatched styling, a custom OWL/Calendar renderer extension is the preferred approach rather than relying solely on CSS or unsupported DOM manipulation.
Hope this works for you! If you need any help implementing this or want a more optimized approach, feel free to reach out for further discussion.
Regards,
Zehntech Technologies Inc.
I did it! Here is the code.
is_hatched = fields.Boolean(
string="¿Está rayado?",
compute="_compute_is_hatched",
store=False
)
@api.depends('stage_id')
def _compute_is_hatched(self):
for lead in self:
# Si la oportunidad está en la etapa 'Rallada', activamos el patrón nativo
if lead.stage_id and lead.stage_id.name == 'Rallada':
lead.is_hatched = True
else:
lead.is_hatched = False<?xml version="1.0" encoding="utf-8"?> <odoo> <record id="view_crm_lead_calendar_hatched_inherit" model="ir.ui.view"> <field name="name">crm.lead.calendar.hatched.inherit</field> <field name="model">crm.lead</field> <field name="inherit_id" ref="crm.crm_case_calendar_view_leads"/> <field name="arch" type="xml"> <xpath expr="//calendar" position="inside"> <field name="is_hatched" invisible="1"/> </xpath> </field> </record> </odoo>
Yes, it must be possible because the native hr_holidays (Time Off) module does exactly what I want to achieve.If you look at the Time Off calendar view (hr.leave), when a leave request is not yet approved (in 'To Approve' status), Odoo dynamically applies that exact same hatched/striped CSS pattern to the calendar event.
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
Registrati| Post correlati | Risposte | Visualizzazioni | Attività | |
|---|---|---|---|---|
|
|
1
ago 23
|
3151 | ||
|
|
1
feb 25
|
3135 | ||
|
|
1
mag 26
|
1086 | ||
|
|
1
feb 26
|
2640 | ||
|
|
2
lug 25
|
4399 |
I'll let you after testing.
Let you know after testing.
As I've explored about this and want to share that don't touch this calendar view because there is not any single file for JS or XML where you can inject your custom code. see below example for <a> tag.
return (preact.createElement(internal$1.StandardEvent, Object.assign({}, props, { elClasses: ['fc-daygrid-event', 'fc-daygrid-block-event', 'fc-h-event'], defaultTimeFormat: DEFAULT_TABLE_EVENT_TIME_FORMAT, defaultDisplayEventEnd: props.defaultDisplayEventEnd, disableResizing: !props.seg.eventRange.def.allDay })));
I'll check what you share about time off.