Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1005 Vistas

Apart from just showing the name and time I want it to show more information 

The odoo is hosted on a vps and is v17 Enterprise, if anyone knows about the customization or maybe some documentation they have found.


Avatar
Descartar
Mejor respuesta

Hi,

Add a Computed Display Field + Inherit the Calendar View

Create a new field in a custom module to compute the display label. 

from odoo import models, fields


class ProjectTask(models.Model):

    _inherit = 'project.task'


    calendar_label = fields.Char(

        string="Calendar Label",

        compute="_compute_calendar_label",

        store=False

    )


    def _compute_calendar_label(self):

        for task in self:

            priority = dict(self._fields['priority'].selection).get(task.priority, '')

            user = task.user_id.name or ''

            task.calendar_label = f"{task.name} [{priority}] - {user}"


Inherit the Calendar View

Now replace the default label ( name ) with your new computed field ( calendar_label ).


<odoo>

    <record id="project_task_calendar_custom" model="ir.ui.view">

        <field name="name">project.task.calendar.inherit</field>

        <field name="model">project.task</field>

        <field name="inherit_id" ref="project.view_task_calendar"/>

        <field name="arch" type="xml">

            <!-- Replace name field used as label -->

            <xpath expr="//field[@name='name']" position="replace">

                <field name="calendar_label"/>

            </xpath>

        </field>

    </record>

</odoo>


I hope it is of full use.

Avatar
Descartar
Mejor respuesta

Hi,

Please refer to the code below:

Python:


class ProjectTask(models.Model):

    _inherit = 'project.task'


    custom_title = fields.Char(string="Custom Calendar Title",

                               compute="_compute_custom_title")


    def _compute_custom_title(self):

        """

        Compute the custom title for calendar view display.


        This method sets the `custom_title` field by combining the task's

        stage name and task name in the format: [Stage] Task Name.

        Example:

            If a task is in stage "In Progress" and named "Fix Bug",

            the computed custom_title will be "[In Progress] Fix Bug".

        """

        for task in self:

            task.custom_title = f"[{task.stage_id.name}] {task.name}"


XML:


<record id="view_task_calendar" model="ir.ui.view">

    <field name="name">project.task.view.calendar</field>

    <field name="model">project.task</field>

    <field name="inherit_id" ref="view_task_calendar"/>

    <field name="mode">primary</field>

    <field name="arch" type="xml">

        <xpath expr="//calendar" position="attributes">

            <attribute name="name">custom_title</attribute>

        </xpath>

    </field>

</record>


Hope it helps.

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
abr 25
3528
1
feb 23
3247
0
sept 20
3744
0
oct 24
771
3
sept 24
2176