Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ addon | version | maintainers | summary
[helpdesk_mgmt_timesheet](helpdesk_mgmt_timesheet/) | 17.0.1.0.4 | | Add HR Timesheet to the tickets for Helpdesk Management.
[helpdesk_mgmtsystem_nonconformity](helpdesk_mgmtsystem_nonconformity/) | 17.0.1.0.0 | <a href='https://github.com/victoralmau'><img src='https://github.com/victoralmau.png' width='32' height='32' style='border-radius:50%;' alt='victoralmau'/></a> | Links helpdesk tickets with nonconformities
[helpdesk_portal_restriction](helpdesk_portal_restriction/) | 17.0.1.0.0 | <a href='https://github.com/lbarry-apsl'><img src='https://github.com/lbarry-apsl.png' width='32' height='32' style='border-radius:50%;' alt='lbarry-apsl'/></a> | Helpdesk Portal Restriction
[helpdesk_ticket_close_inactive](helpdesk_ticket_close_inactive/) | 17.0.1.1.1 | <a href='https://github.com/miquelalzanillas'><img src='https://github.com/miquelalzanillas.png' width='32' height='32' style='border-radius:50%;' alt='miquelalzanillas'/></a> | Helpdesk Ticket Close Inactive
[helpdesk_ticket_close_inactive](helpdesk_ticket_close_inactive/) | 17.0.1.1.2 | <a href='https://github.com/miquelalzanillas'><img src='https://github.com/miquelalzanillas.png' width='32' height='32' style='border-radius:50%;' alt='miquelalzanillas'/></a> | Helpdesk Ticket Close Inactive
[helpdesk_ticket_open_tab](helpdesk_ticket_open_tab/) | 17.0.1.0.0 | <a href='https://github.com/peluko00'><img src='https://github.com/peluko00.png' width='32' height='32' style='border-radius:50%;' alt='peluko00'/></a> | Helpdesk Ticket Open Tab
[helpdesk_ticket_partner_response](helpdesk_ticket_partner_response/) | 17.0.1.0.2 | <a href='https://github.com/peluko00'><img src='https://github.com/peluko00.png' width='32' height='32' style='border-radius:50%;' alt='peluko00'/></a> | Change ticket stage when partner response
[helpdesk_ticket_related](helpdesk_ticket_related/) | 17.0.1.0.0 | <a href='https://github.com/peluko00'><img src='https://github.com/peluko00.png' width='32' height='32' style='border-radius:50%;' alt='peluko00'/></a> | Link tickets to each other
Expand Down
2 changes: 1 addition & 1 deletion helpdesk_ticket_close_inactive/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Helpdesk Ticket Close Inactive
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:516963a440547c25f06f12debb73b865aedb8a4357d8e59373985dd4358f246b
!! source digest: sha256:ef39f34f7ae0a0d8cca62747c744607375f734b452b942289b0a51e09e72a150
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
Expand Down
2 changes: 1 addition & 1 deletion helpdesk_ticket_close_inactive/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Helpdesk Ticket Close Inactive",
"version": "17.0.1.1.1",
"version": "17.0.1.1.2",
"development_status": "Alpha",
"category": "Helpdesk",
"website": "https://github.com/OCA/helpdesk",
Expand Down
15 changes: 9 additions & 6 deletions helpdesk_ticket_close_inactive/models/helpdesk_ticket_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def close_team_inactive_tickets(self):
else:
teams = self.search([("close_inactive_tickets", "=", True)])

warning_email_ids = []
closing_email_ids = []

for team_id in teams:
ticket_stage_ids = team_id.ticket_stage_ids.ids
ticket_category_ids = team_id.ticket_category_ids.ids
Expand Down Expand Up @@ -106,8 +109,7 @@ def close_team_inactive_tickets(self):
search_domain.append(("category_id", "in", ticket_category_ids))

warning_ticket_ids = self.env["helpdesk.ticket"].search(search_domain)
warning_email_ids = []
closing_email_ids = []

if warning_ticket_ids:
for ticket in warning_ticket_ids:
# Set template context
Expand Down Expand Up @@ -160,7 +162,8 @@ def close_team_inactive_tickets(self):
msg = "Ticket closed automatically because have \
reached the inactivity days limit"
ticket.message_post(body=msg)
return {
"warning_email_ids": warning_email_ids,
"closing_email_ids": closing_email_ids,
}

return {
"warning_email_ids": warning_email_ids,
"closing_email_ids": closing_email_ids,
}
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Helpdesk Ticket Close Inactive</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:516963a440547c25f06f12debb73b865aedb8a4357d8e59373985dd4358f246b
!! source digest: sha256:ef39f34f7ae0a0d8cca62747c744607375f734b452b942289b0a51e09e72a150
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/helpdesk/tree/17.0/helpdesk_ticket_close_inactive"><img alt="OCA/helpdesk" src="https://img.shields.io/badge/github-OCA%2Fhelpdesk-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/helpdesk-17-0/helpdesk-17-0-helpdesk_ticket_close_inactive"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/helpdesk&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds an option to configure a cron job that automatically closes
Expand Down
25 changes: 25 additions & 0 deletions helpdesk_ticket_close_inactive/tests/test_ticket_autoclose.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,28 @@ def test_close_tickets_without_category(self):
self.stage_closing,
"Ticket should be moved to the closing stage",
)

def test_multiple_teams_processed_by_cron(self):
"""Test that the cron processes all active teams in a single execution."""
self.ticket.write({"last_stage_update": datetime.today() - timedelta(days=15)})
self.ticket2.write({"last_stage_update": datetime.today() - timedelta(days=15)})
result = self.env["helpdesk.ticket.team"].close_team_inactive_tickets()

# Assert BOTH tickets were successfully updated to the closing stage
self.assertEqual(
self.ticket.stage_id,
self.stage_closing,
"First team ticket should be closed by multi-team cron process.",
)
self.assertEqual(
self.ticket2.stage_id,
self.stage_closing,
"Second team ticket should be closed by multi-team cron process.",
)

# Assert exactly 2 closing emails were tracked (one per closed ticket)
self.assertEqual(
len(result.get("closing_email_ids", [])),
2,
"The cron should have tracked exactly 2 closing email IDs.",
)
Loading