odoo18/addons_extensions/project_task_timesheet_exte.../models/timesheets.py

20 lines
688 B
Python

from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
class AccountAnalyticLine(models.Model):
_inherit = 'account.analytic.line'
stage_id = fields.Many2one(
'project.task.type',
string="Stage",
domain="[('id', 'in', stage_ids)]"
)
stage_ids = fields.Many2many('project.task.type',related="task_id.project_id.type_ids")
@api.constrains('stage_id', 'task_id')
def _check_stage_required(self):
for line in self:
if line.task_id.show_approval_flow and not line.stage_id:
raise ValidationError(_("Stage is required when Approval Flow is enabled for this task."))