تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
2542 أدوات العرض

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


الصورة الرمزية
إهمال

@Odoo - any news?

الكاتب

But there seems to be no answer.

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

أفضل إجابة

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.

الصورة الرمزية
إهمال
أفضل إجابة

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


الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
مايو 23
4653
1
أكتوبر 22
3508
0
نوفمبر 21
2429
1
مايو 21
3105
1
سبتمبر 20
8528