Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
961 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
apr. 25
3484
1
feb. 23
3209
0
sep. 20
3739
0
okt. 24
768
3
sep. 24
2141