diff --git a/README.md b/README.md
index 5e18c2060e..1ff7e0c847 100644
--- a/README.md
+++ b/README.md
@@ -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 |
| Links helpdesk tickets with nonconformities
[helpdesk_portal_restriction](helpdesk_portal_restriction/) | 17.0.1.0.0 |
| Helpdesk Portal Restriction
-[helpdesk_ticket_close_inactive](helpdesk_ticket_close_inactive/) | 17.0.1.1.1 |
| Helpdesk Ticket Close Inactive
+[helpdesk_ticket_close_inactive](helpdesk_ticket_close_inactive/) | 17.0.1.1.2 |
| Helpdesk Ticket Close Inactive
[helpdesk_ticket_open_tab](helpdesk_ticket_open_tab/) | 17.0.1.0.0 |
| Helpdesk Ticket Open Tab
[helpdesk_ticket_partner_response](helpdesk_ticket_partner_response/) | 17.0.1.0.2 |
| Change ticket stage when partner response
[helpdesk_ticket_related](helpdesk_ticket_related/) | 17.0.1.0.0 |
| Link tickets to each other
diff --git a/helpdesk_ticket_close_inactive/README.rst b/helpdesk_ticket_close_inactive/README.rst
index 278a60978d..0e0b5df2bd 100644
--- a/helpdesk_ticket_close_inactive/README.rst
+++ b/helpdesk_ticket_close_inactive/README.rst
@@ -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
diff --git a/helpdesk_ticket_close_inactive/__manifest__.py b/helpdesk_ticket_close_inactive/__manifest__.py
index acbe238f4c..cc16abd747 100644
--- a/helpdesk_ticket_close_inactive/__manifest__.py
+++ b/helpdesk_ticket_close_inactive/__manifest__.py
@@ -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",
diff --git a/helpdesk_ticket_close_inactive/models/helpdesk_ticket_team.py b/helpdesk_ticket_close_inactive/models/helpdesk_ticket_team.py
index b70c734356..1ed376ae00 100644
--- a/helpdesk_ticket_close_inactive/models/helpdesk_ticket_team.py
+++ b/helpdesk_ticket_close_inactive/models/helpdesk_ticket_team.py
@@ -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
@@ -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
@@ -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,
+ }
diff --git a/helpdesk_ticket_close_inactive/static/description/index.html b/helpdesk_ticket_close_inactive/static/description/index.html
index 6761ef5c13..54f92ecb0c 100644
--- a/helpdesk_ticket_close_inactive/static/description/index.html
+++ b/helpdesk_ticket_close_inactive/static/description/index.html
@@ -372,7 +372,7 @@
Adds an option to configure a cron job that automatically closes diff --git a/helpdesk_ticket_close_inactive/tests/test_ticket_autoclose.py b/helpdesk_ticket_close_inactive/tests/test_ticket_autoclose.py index 7dd2d5879e..4d819afd24 100644 --- a/helpdesk_ticket_close_inactive/tests/test_ticket_autoclose.py +++ b/helpdesk_ticket_close_inactive/tests/test_ticket_autoclose.py @@ -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.", + )