Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2552 Lượt xem

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


Ảnh đại diện
Huỷ bỏ

@Odoo - any news?

Tác giả

But there seems to be no answer.

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

Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 5 23
4687
1
thg 10 22
3523
0
thg 11 21
2455
1
thg 5 21
3122
1
thg 9 20
8536