user own estimations

This commit is contained in:
pranaysaidurga 2026-05-07 14:14:41 +05:30
parent 9c33507a45
commit e2d6a8c417
2 changed files with 29 additions and 19 deletions

View File

@ -68,16 +68,16 @@ class projectTask(models.Model):
return super(projectTask, self).write(vals) return super(projectTask, self).write(vals)
#
@api.constrains('name') # @api.constrains('name')
def _check_task_name(self): # def _check_task_name(self):
pattern = r'^[A-Za-z0-9 ]+$' # only letters, numbers, space # pattern = r'^[A-Za-z0-9 ]+$' # only letters, numbers, space
#
for rec in self: # for rec in self:
if rec.name and not re.match(pattern, rec.name): # if rec.name and not re.match(pattern, rec.name):
raise ValidationError( # raise ValidationError(
"Task name can only contain letters, numbers, and spaces." # "Task name can only contain letters, numbers, and spaces."
) # )
sequence_name = fields.Char("Sequence", copy=False) sequence_name = fields.Char("Sequence", copy=False)
is_generic = fields.Boolean(string='Generic', default=True, tracking=True, is_generic = fields.Boolean(string='Generic', default=True, tracking=True,
@ -1495,15 +1495,25 @@ class projectTaskTimelines(models.Model):
"project.group_project_manager") or current_user == task.project_id.user_id or current_user == task.responsible_lead or current_user == task.project_id.project_lead: "project.group_project_manager") or current_user == task.project_id.user_id or current_user == task.responsible_lead or current_user == task.project_id.project_lead:
task.has_edit_access = True task.has_edit_access = True
@api.depends("project_id","task_id") @api.depends("project_id", "task_id")
def _compute_estimated_time_readonly(self): def _compute_estimated_time_readonly(self):
for task in self: for record in self:
task.estimated_time_readonly = True record.estimated_time_readonly = True
if not (record.project_id and record.task_id):
continue
current_user = self.env.user current_user = self.env.user
if task.task_id and task.project_id: task = record.task_id
is_first_stage = task.task_id.stage_id.sequence == min(task.task_id.project_id.type_ids.mapped('sequence')) project = record.project_id
if is_first_stage or current_user == task.project_id.user_id: stage_sequences = task.project_id.type_ids.mapped("sequence")
task.estimated_time_readonly = False is_first_stage = stage_sequences and task.stage_id.sequence == min(stage_sequences)
is_project_user = current_user == project.user_id
is_authorized_user = current_user in [project.user_id, project.project_lead,
record.assigned_to, record.responsible_lead]
can_edit = (is_first_stage or is_project_user) and is_authorized_user
record.estimated_time_readonly = not can_edit
@api.depends('task_id','task_id.timesheet_ids', 'stage_id') @api.depends('task_id','task_id.timesheet_ids', 'stage_id')
def _compute_actual_time(self): def _compute_actual_time(self):

View File

@ -69,14 +69,14 @@
<page string="Assignees Timelines" invisible="not show_approval_flow"> <page string="Assignees Timelines" invisible="not show_approval_flow">
<button name="button_update_assignees" type="object" string="Update Assignees" class="oe_highlight"/> <button name="button_update_assignees" type="object" string="Update Assignees" class="oe_highlight"/>
<button name="action_assign_approx_deadlines" type="object" string="Assign Approx Timeline" class="oe_highlight"/> <button name="action_assign_approx_deadlines" type="object" string="Assign Approx Timeline" class="oe_highlight"/>
<field name="assignees_timelines" context="{'default_task_id': id}" > <field name="assignees_timelines" context="{'default_task_id': id}" options="{'no_open': True}">
<list editable="bottom"> <list editable="bottom">
<field name="stage_id" readonly="not has_edit_access"/> <field name="stage_id" readonly="not has_edit_access"/>
<field name="responsible_lead" readonly="not has_edit_access"/> <field name="responsible_lead" readonly="not has_edit_access"/>
<field name="team_id" readonly="not has_edit_access"/> <field name="team_id" readonly="not has_edit_access"/>
<field name="assigned_to" readonly="not has_edit_access"/> <field name="assigned_to" readonly="not has_edit_access"/>
<!-- <field name="team_all_member_ids" widget="many2many_tags"/>--> <!-- <field name="team_all_member_ids" widget="many2many_tags"/>-->
<field name="estimated_time" widget="float_time" readonly="not has_edit_access or estimated_time_readonly"/> <field name="estimated_time" widget="float_time" readonly="estimated_time_readonly"/>
<field name="actual_time" readonly="1" optional="hide" widget="float_time"/> <field name="actual_time" readonly="1" optional="hide" widget="float_time"/>
<field name="has_edit_access" column_invisible="True" optional="hide" readonly="1"/> <field name="has_edit_access" column_invisible="True" optional="hide" readonly="1"/>
<field name="estimated_time_readonly" column_invisible="True" optional="hide" readonly="1"/> <field name="estimated_time_readonly" column_invisible="True" optional="hide" readonly="1"/>