enhancements of PMT
This commit is contained in:
parent
f118600ab6
commit
3092032fee
|
|
@ -165,6 +165,7 @@ class projectTask(models.Model):
|
|||
|
||||
|
||||
has_supervisor_access = fields.Boolean(compute="_compute_has_supervisor_access")
|
||||
show_reassign_button = fields.Boolean(compute="_compute_show_reassign_button")
|
||||
actual_hours = fields.Float(
|
||||
string="Actual Hours",
|
||||
compute="_compute_actual_hours",
|
||||
|
|
@ -539,6 +540,20 @@ class projectTask(models.Model):
|
|||
if current_user.has_group("project.group_project_manager") or current_user == task.project_id.user_id or current_user == task.project_id.project_lead or (current_user.id in list(set(create_access_users.ids)) and task.stage_id.id == first_stage.id):
|
||||
task.has_supervisor_access = True
|
||||
|
||||
|
||||
@api.depends("project_id", "project_id.user_id", "project_id.project_lead")
|
||||
def _compute_show_reassign_button(self):
|
||||
current_user = self.env.user
|
||||
is_admin = current_user.has_group("base.group_system") or current_user.has_group("project.group_project_manager")
|
||||
for task in self:
|
||||
task.show_reassign_button = bool(
|
||||
task.project_id
|
||||
and (
|
||||
is_admin
|
||||
or current_user == task.project_id.user_id
|
||||
or current_user == task.project_id.project_lead
|
||||
)
|
||||
)
|
||||
@api.depends('assignees_timelines.estimated_time', 'show_approval_flow')
|
||||
def _compute_estimated_hours(self):
|
||||
for task in self:
|
||||
|
|
@ -702,6 +717,12 @@ class projectTask(models.Model):
|
|||
key=lambda s: s.sequence)[:1]
|
||||
|
||||
approval_not_required = False
|
||||
can_skip_approval_stage = (
|
||||
user in task.involved_user_ids
|
||||
or user in [project_manager, project_lead]
|
||||
or user.has_group("project.group_project_manager")
|
||||
or user.has_group("base.group_system")
|
||||
)
|
||||
|
||||
# Compute buttons visibility
|
||||
if current_timeline:
|
||||
|
|
@ -720,7 +741,7 @@ class projectTask(models.Model):
|
|||
|
||||
if (
|
||||
approval_not_required
|
||||
and user in task.involved_user_ids
|
||||
and can_skip_approval_stage
|
||||
and task.approval_status != "submitted"
|
||||
):
|
||||
task.show_submission_button = True
|
||||
|
|
@ -749,7 +770,7 @@ class projectTask(models.Model):
|
|||
|
||||
else:
|
||||
approval_not_required = True
|
||||
if user in task.involved_user_ids and task.approval_status != "submitted":
|
||||
if can_skip_approval_stage and task.approval_status != "submitted":
|
||||
task.show_submission_button = True
|
||||
task.show_skip_approval_button = True
|
||||
|
||||
|
|
@ -1203,9 +1224,10 @@ class projectTask(models.Model):
|
|||
def _append_reassignment_history(self, stage, users, reason):
|
||||
self.ensure_one()
|
||||
formatted_datetime = self._get_current_datetime_formatted()
|
||||
entry = "[%s] Stage: %s | Users: %s | Reason: %s" % (
|
||||
entry = "[%s] Stage: %s | Assigned By: %s | Assigned To: %s | Reason: %s" % (
|
||||
formatted_datetime,
|
||||
stage.name,
|
||||
self.env.user.name,
|
||||
", ".join(users.mapped('name')),
|
||||
reason or "",
|
||||
)
|
||||
|
|
@ -1216,6 +1238,8 @@ class projectTask(models.Model):
|
|||
|
||||
def action_open_reassign_wizard(self):
|
||||
self.ensure_one()
|
||||
if not self.show_reassign_button:
|
||||
raise UserError(_("Only the project manager, project lead, or administrator can re-assign assignees."))
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"name": _("Re-Assign Assignees"),
|
||||
|
|
@ -1903,3 +1927,4 @@ class projectTaskTimelines(models.Model):
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
<record id="project_task_search_project_by_module" model="ir.ui.view">
|
||||
<field name="name">project.task.search.project.by.module</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="inherit_id" eval="False"/>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="name" string="Task"/>
|
||||
|
|
@ -82,3 +83,4 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<div class="o_task_assignees_inline">
|
||||
<field name="user_ids" nolabel="1" widget="involved_assignee_avatar_user" domain="[('id', 'in', involved_user_ids)]" options="{'no_create': True, 'no_quick_create': True, 'no_create_edit': True}" invisible="is_generic"/>
|
||||
<field name="user_ids" nolabel="1" class="o_task_user_field" options="{'no_open': True, 'no_quick_create': True}" widget="many2many_avatar_user" domain="[('id', 'in', assignee_domain_ids)]" invisible="not is_generic"/>
|
||||
<button name="action_open_reassign_wizard" type="object" string="Re-Assign" title="Re-Assign Assignees" class="btn btn-secondary btn-sm o_task_reassign_button" invisible="record_paused"/>
|
||||
<button name="action_open_reassign_wizard" type="object" string="Re-Assign" title="Re-Assign Assignees" class="btn btn-secondary btn-sm o_task_reassign_button" invisible="record_paused or not show_reassign_button"/>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='timesheet_ids']" position="attributes">
|
||||
|
|
@ -120,6 +120,7 @@
|
|||
<field name="show_refuse_button" invisible="1"/>
|
||||
<field name="show_back_button" invisible="1"/>
|
||||
<field name="has_supervisor_access" invisible="1"/>
|
||||
<field name="show_reassign_button" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='stage_id']" position="attributes">
|
||||
<attribute name="readonly">show_approval_flow or state in ['1_canceled','04_waiting_normal'] or record_paused</attribute>
|
||||
|
|
@ -213,7 +214,9 @@
|
|||
<filter name="task_need_approval" string="Need Approval" domain="[('approval_status', '=', 'submitted')]"/>
|
||||
<filter name="task_approved" string="Approved" domain="[('approval_status', '=', 'approved')]"/>
|
||||
<filter name="task_rejected" string="Rejected" domain="[('approval_status', '=', 'refused')]"/>
|
||||
</xpath> </field>
|
||||
</xpath>
|
||||
<!-- <xpath expr="//searchpanel" position="replace"/>-->
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="project_task_kanban_task_id_module_base" model="ir.ui.view">
|
||||
|
|
@ -308,3 +311,4 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue