[FIX] helpdesk_mgmt: do not auto-assign tickets to portal users - #1086
Open
nericervin wants to merge 1 commit into
Open
[FIX] helpdesk_mgmt: do not auto-assign tickets to portal users#1086nericervin wants to merge 1 commit into
nericervin wants to merge 1 commit into
Conversation
pedrobaeza
requested changes
Aug 15, 2026
pedrobaeza
left a comment
Member
There was a problem hiding this comment.
Please don't include slop tests generated by AI. You just need to check the new case, not all the variants.
| "summary": """ | ||
| Helpdesk""", | ||
| "version": "18.0.1.17.1", | ||
| "version": "18.0.1.17.2", |
Member
There was a problem hiding this comment.
Don't modify module version. It will be done by the bot.
When "Auto assign User" is enabled on the company, a ticket submitted by a portal user ends up assigned to that portal user: the customer who filed the ticket becomes its assignee, so it never shows up as unassigned and nobody picks it up. sudo() does not change env.uid, it only elevates privileges, so self.env.user inside default_get() is still the portal user. The branch with a team is safe by accident (a portal user is not a member of the team), but the branch without a team assigns unconditionally. Portal controllers hit that second branch, because they pass the team in the values of create() and not in the defaults. Skip the auto-assignment when the current user is a shared user. This is consistent with the domain of user_id itself, which already excludes them.
nericervin
force-pushed
the
18.0-fix-helpdesk_mgmt-portal-auto-assign
branch
from
August 15, 2026 22:26
23160f5 to
bd5ef25
Compare
Author
|
Fair point. Reduced to a single test for the new case. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Auto assign User is enabled on the company, a ticket submitted by a
portal user ends up assigned to that portal user. The customer who filed the
ticket becomes its assignee, which also means the ticket counts as assigned
and never shows up as unassigned, so nobody picks it up.
How to reproduce
The ticket is created with
user_idset to the portal user.Note that
sudo()does not changeenv.uid, it only elevates privileges, soself.env.userinsidedefault_get()is still the portal user.Cause
helpdesk_mgmt/models/helpdesk_ticket.py,default_get():The branch with a team is safe by accident: a portal user is not a member of
the team, so the membership check rejects it. The branch without a team
assigns unconditionally.
Portal controllers hit that second branch, because they pass the team in the
values of
create()and not in the defaults:team_idis therefore not amissing field,
default_get()is not called for it, anddefaults.get("team_id")is falsy.helpdesk_mgmt's own portal controller happens to escape the issue, because_prepare_submit_ticket_vals()sets"user_id": Falseexplicitly. Any othercontroller that does not set it — a custom website form, an API import — hits
the bug. A website form with
auth="public"runs asbase.public_user, soin that case tickets end up assigned to the public user, which is even less
useful than being assigned to the customer.
Fix
Skip the auto-assignment when the current user is a shared user
(
share == True, i.e. portal or public). This is consistent with the domainof
user_iditself, which already excludes shared users:Internal users are unaffected: the existing behaviour (creator becomes the
assignee) is preserved, and a regression test covers it.
Tests
Four tests added to
helpdesk_mgmt/tests/test_helpdesk_portal.py, reusing theexisting
TestHelpdeskPortalBasefixtures: portal user with and without ateam,
base.public_user, and an internal user to make sure the currentbehaviour does not change.
Other branches
The same code is present in
17.0.16.0is not affected: thehelpdesk_mgmt_ticket_auto_assignfield does not exist there. Happy tobackport to
17.0if you want it in the same PR or in a separate one.