Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
2265 Näkymät

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


Avatar
Hylkää

@Odoo - any news?

Tekijä

But there seems to be no answer.

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

Paras vastaus

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
Hylkää
Paras vastaus

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


Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
3
toukok. 23
4285
1
lokak. 22
3245
0
marrask. 21
2172
1
toukok. 21
2834
1
syysk. 20
8253