9 Commits

Author SHA1 Message Date
Stéphan Sainléger
923a4f16c4 [IMP] helpdesk_user_default_ticket_team: document behaviour and convert README to markdown
- Add docstrings to ``_compute_user_id``, ``create`` and
  ``_define_user_id`` and clarify the inline comments describing the
  team-leader fallback rules.
- Convert ``README.rst`` to ``README.md``, documenting usage, the
  graceful handling of partners without a linked user, and how to run
  the test suite.
2026-06-25 15:39:54 +02:00
Stéphan Sainléger
b58fb77f3a [ADD] helpdesk_user_default_ticket_team: add test coverage
Add a ``TransactionCase`` test suite covering the module behaviour:

- ``_define_user_id`` decision rules (no team, no current user, user not
  in team, user in team, team without leader).
- ``create`` auto-assignment (with/without partner, with/without default
  team, explicit team not overridden, partner without linked user, batch
  ``vals_list`` creation).
- ``_compute_user_id`` recomputation on team change.
- Full portal creation flow (team + project + user) and presence of the
  ``default_helpdesk_ticket_team_id`` field on ``res.users``.
2026-06-25 15:39:30 +02:00
Stéphan Sainléger
6b8906325e [FIX] helpdesk_user_default_ticket_team: handle partner without linked user
``create`` accessed ``partner.user_ids[0]`` which raised ``IndexError``
when the ticket's partner had no linked user (e.g. a plain contact).

Use ``partner.user_ids[:1]`` so a partner without a user yields an empty
recordset, which the following ``if not user`` guard handles gracefully,
leaving the ticket's team untouched.
2026-06-25 15:39:23 +02:00
Stéphan Sainléger
1bfe51109e [REF] helpdesk_user_default_ticket_team: extract user assignment into `_define_user_id`
Extract the team-leader assignment logic into a dedicated
``_define_user_id`` helper, shared between ``_compute_user_id`` and
``create``:

- ``_compute_user_id`` now delegates to ``_define_user_id`` instead of
  inlining the membership/leader checks.
- ``create`` also assigns ``user_id`` from the default team via the same
  helper, so a portal-created ticket gets the team leader assigned.

This centralises the decision (keep current user / fall back to team
leader) in a single, reusable place.
2026-06-25 15:39:12 +02:00
Stéphan Sainléger
a2b2256a17 [IMP] helpdesk_user_default_ticket_team: auto-assign team leader on team change
In helpdesk_mgmt v16, ``_compute_user_id`` automatically filled
``user_id`` with ``team_id.alias_user_id`` when the team was set and
no user was assigned. This behaviour was removed in v18: the compute
now only clears ``user_id`` when the assigned user is not a member of
the selected team, without assigning anyone in its place.

This commit restores equivalent behaviour using ``team_id.user_id``
(the Team Leader field) instead of ``alias_user_id``:

- When ``team_id`` changes and the current ``user_id`` is not a member
  of the new team, the Team Leader is assigned automatically.
- If the team has no leader configured, ``user_id`` is left unchanged
  to avoid creating unassigned tickets.
- ``super()`` is not called: this is a full replacement of the v18
  OCA behaviour, not an extension of it.

Also updates README.rst to document the new auto-assignment behaviour.
2026-06-12 16:29:33 +02:00
Stéphan Sainléger
baf64eac45 [MIG] helpdesk_user_default_ticket_team: migrate to 18.0 2026-03-17 21:31:15 +01:00
Stéphan Sainléger
0720f67a14 [MIG] init 18.0 2026-01-16 16:25:10 +01:00
Stéphan Sainléger
25da7f6a8f [IMP] helpdesk_user_default_ticket_team: fill project field
if defined in the helpdesk team
2025-06-03 09:24:56 +02:00
Stéphan Sainléger
5f74000f5c [ADD] helpdesk_user_default_ticket_team: create add-on 2025-06-03 09:24:56 +02:00