Skip to content

Commit

Permalink
[FIX] helpdesk_mgmt_activity: perform action visible
Browse files Browse the repository at this point in the history
Show button only in new stage
  • Loading branch information
geomer198 committed Oct 17, 2024
1 parent 8e26477 commit a605955
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions helpdesk_mgmt_activity/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class HelpdeskTicket(models.Model):
store=True,
index=True,
)
is_new_stage = fields.Boolean(compute="_compute_is_new_stage")

@api.model
def _selection_record_ref(self):
Expand Down Expand Up @@ -59,6 +60,11 @@ def _get_team_stages(self, teams):
"""
return {team.id: team._get_applicable_stages() for team in teams}

def _compute_is_new_stage(self):
for ticket in self:
new_stage = ticket.team_id._get_applicable_stages()[:1]
ticket.is_new_stage = ticket.stage_id == new_stage

Check warning on line 66 in helpdesk_mgmt_activity/models/helpdesk_ticket.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/helpdesk_ticket.py#L65-L66

Added lines #L65 - L66 were not covered by tests

@api.depends("stage_id")
def _compute_next_stage_id(self):
"""Compute next stage for ticket"""
Expand Down
3 changes: 2 additions & 1 deletion helpdesk_mgmt_activity/views/helpdesk_ticket_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
<field name="priority">99</field>
<field name="arch" type="xml">
<header position="inside">
<field name="is_new_stage" invisible="1" />
<field name="can_create_activity" invisible="1" />
<button
string="Perform Action"
class="btn btn-primary"
name="perform_action"
type="object"
attrs="{'invisible': [('can_create_activity', '=', False)]}"
attrs="{'invisible': [('can_create_activity', '=', False), ('is_new_stage', '=', True)]}"
/>
</header>
<group name="main" position="inside">
Expand Down

0 comments on commit a605955

Please sign in to comment.