How can I prevent time entry on a finished project or task?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Бухоблік
- Склад
- PoS
- Project
- MRP
Це запитання позначене
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:
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
РеєстраціяRelated Posts | Відповіді | Переглядів | Дія | |
---|---|---|---|---|
|
3
трав. 23
|
4294 | ||
|
1
жовт. 22
|
3248 | ||
|
0
лист. 21
|
2176 | ||
|
1
трав. 21
|
2836 | ||
|
1
вер. 20
|
8263 |
I've also asked a similar question:
https://www.odoo.com/forum/help-1/unable-users-to-timesheet-hours-on-closed-folded-projects-and-or-tasks-228861
@Odoo - any news?
But there seems to be no answer.
In most other time registration software this is a standard feature !