Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
2264 Ansichten

How can I prevent time entry on a finished project or task?


Avatar
Verwerfen

@Odoo - any news?

Autor

But there seems to be no answer.

In most other time registration software this is a standard feature !

Beste Antwort

Hi,

Please refer to the code:


from odoo import models, api

from odoo.exceptions import ValidationError


class AnalyticLine(models.Model):

    _inherit = "account.analytic.line"


    @api.model

    def create(self, vals):

        task_id = vals.get("task_id")

        if task_id:

            task = self.env["project.task"].browse(task_id)

            if task.is_closed:

                raise ValidationError("You cannot log time on a closed task.")

        return super().create(vals)


    def write(self, vals):

        if "task_id" in vals:

            task = self.env["project.task"].browse(vals["task_id"])

            if task.is_closed:

                raise ValidationError("You cannot reassign timesheet to a closed task.")

        return super().write(vals)


Hope it helps.

Avatar
Verwerfen
Beste Antwort

On the Settings tab of the Project, uncheck "Timesheets - Log time on tasks" to prevent further timesheeting:


Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
3
Mai 23
4283
1
Okt. 22
3244
0
Nov. 21
2172
1
Mai 21
2833
1
Sept. 20
8252