Skip to content
Open
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
174 changes: 174 additions & 0 deletions helpdesk_mgmt_team_customer/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=============================
Helpdesk Ticket Team Customer
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:80bb4d25d91b2d6aa1933125d74bba0af0cc9a8759476c825eb5298fc9b68449
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-solvosci%2Fhelpdesk-lightgray.png?logo=github
:target: https://github.com/solvosci/helpdesk/tree/17.0/helpdesk_mgmt_team_customer
:alt: solvosci/helpdesk

|badge1| |badge2| |badge3|

Overview
========

Allows dynamic control over which contact (partner_id) on ticket, based
on the configuration of the assigned Helpdesk Team (team_id). The logic
works as follows:

- If the team has a default contact, it will fill the contact field with
that value.
- If the team has a unique contact, only that contact will be available.
- If the team has a list of allowed contacts, only those contacts will
be available.
- If the team has no restrictions, all contacts will be available.

Use Case
========

This module is designed for organizations that structure their Helpdesk
teams around customers, rather than functional support areas.

A typical use case is a software development or services company where:

- Each customer has a dedicated Helpdesk Team.
- Developers and support agents are assigned to customer-specific teams.
- The Helpdesk dashboard is used to track workload per customer (e.g.
"Customer X – 4 open tickets").

In this setup, every ticket created for a given team is implicitly
related to a specific customer. However, in standard Odoo, both fields
must still be manually selected:

- Team: Customer X
- Customer: Customer X

This repetition is error-prone and slows down ticket creation.

Module Purpose
==============

The goal of this module is to streamline ticket creation and prevent
inconsistent data by linking Helpdesk Teams to one or more allowed
customers.

Depending on the team configuration, the module can:

- Automatically set a default customer when a team is selected.
- Restrict the customer field to a single allowed customer.
- Restrict the customer field to a predefined list of customers.

As a result:

- Ticket creation is faster.
- The risk of assigning a ticket to the wrong customer is reduced.
- The Helpdesk dashboard remains consistently grouped by customer.

Design Rationale
================

Why the restriction goes from Team to Customer
----------------------------------------------

Unlike more common setups where customers are restricted to specific
teams, this module addresses scenarios where:

- Teams represent customer contexts.
- Agents frequently switch between customer-dedicated teams.
- Correct customer assignment is critical for reporting, dashboards, and
contractual scope control.

For these scenarios, enforcing customer consistency at the team level is
both intentional and required.

Why a server-side constraint is required
----------------------------------------

The dynamic domain on the customer field is intended as user guidance,
but it is not sufficient to guarantee data consistency.

In standard Odoo behavior, many2one fields allow on-the-fly record
creation. For example, an agent may type a new customer name and press
Enter, creating a new partner that bypasses the UI domain restriction.

For this reason, a server-side constraint is required to ensure that,
when a Helpdesk Team defines an explicit list of allowed customers, no
ticket can be saved with a customer outside that list.

The constraint does not prevent customer creation; it only enforces the
team-to-customer consistency rule at persistence time.

Why Record Rules are not used
-----------------------------

This module does not aim to restrict global access to partners.

Partner availability is contextual and depends on the Helpdesk Team
selected on each ticket. The same user may work with multiple
customer-dedicated teams during the same day.

Record Rules are evaluated at user or group level and are therefore not
well suited for per-record, team-dependent restrictions.

For this reason, the module uses:

- a dynamic domain for user guidance
- a server-side constraint for data consistency

This keeps the implementation simple, predictable, and aligned with
Odoo’s standard interaction patterns.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/solvosci/helpdesk/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/solvosci/helpdesk/issues/new?body=module:%20helpdesk_mgmt_team_customer%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Solvosci

Contributors
------------

- `Solvos <https://www.solvos.es>`__:

- Carlos García <carlos.garcia@solvos.es>
- Dante Pereyra <dante.pereyra@solvos.es>

Maintainers
-----------

This module is part of the `solvosci/helpdesk <https://github.com/solvosci/helpdesk/tree/17.0/helpdesk_mgmt_team_customer>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions helpdesk_mgmt_team_customer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions helpdesk_mgmt_team_customer/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# © 2025 Solvos Consultoría Informática (<http://www.solvos.es>)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Helpdesk Ticket Team Customer",
"category": "Helpdesk",
"website": "https://github.com/OCA/helpdesk",
"license": "AGPL-3",
"summary": (
"Allows dynamic control over which contact (partner_id) on ticket, "
"based on the configuration of the assigned Helpdesk Team (team_id)"
),
"author": "Solvosci, " "Odoo Community Association (OCA)",
"depends": ["helpdesk_mgmt"],
"version": "17.0.1.0.0",
"data": [
"views/helpdesk_ticket_views.xml",
"views/helpdesk_ticket_team_views.xml",
],
"application": False,
"installable": True,
}
2 changes: 2 additions & 0 deletions helpdesk_mgmt_team_customer/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import helpdesk_ticket
from . import helpdesk_ticket_team
60 changes: 60 additions & 0 deletions helpdesk_mgmt_team_customer/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# © 2025 Solvos Consultoría Informática (<http://www.solvos.es>)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class HelpdeskTicket(models.Model):
_inherit = "helpdesk.ticket"

partner_id_domain = fields.Binary(
help="This is the computed domain to filter partners.",
compute="_compute_partner_id_domain",
)

@api.depends(
"team_id",
"team_id.default_partner_id",
"team_id.allowed_partner_ids",
"team_id.is_unique_partner",
)
def _compute_partner_id_domain(self):
for record in self:
if record.team_id:
if record.team_id.default_partner_id and not record.partner_id:
record.partner_id = record.team_id.default_partner_id
if record.team_id.is_unique_partner:
record.partner_id_domain = [
("id", "=", record.team_id.default_partner_id.id)
]
elif record.team_id.allowed_partner_ids:
partners = record.team_id.allowed_partner_ids
if record.team_id.default_partner_id:
partners |= record.team_id.default_partner_id
record.partner_id_domain = [("id", "in", partners.ids)]
else:
record.partner_id_domain = []
else:
record.partner_id_domain = []

@api.constrains("team_id", "partner_id")
def _check_partner_allowed_by_team(self):
for record in self:
if not record.team_id or not record.partner_id:
continue
if (
record.team_id.is_unique_partner
and record.partner_id != record.team_id.default_partner_id
):
raise ValidationError(
_("This partner is not allowed for selected team")
)
elif (
record.team_id.allowed_partner_ids
and record.partner_id not in record.team_id.allowed_partner_ids
and record.partner_id != record.team_id.default_partner_id
):
raise ValidationError(
_("This partner is not allowed for selected team")
)
Comment on lines +41 to +60
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is unnecessary since you will not be capable of select different partners with above restrictions, but maybe I'm wrong.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s necessary because tickets allow the creation of a partner 'on the fly'. I didn’t want to restrict that functionality, but I did want to block the possibility of assigning this new partner to the ticket, since it’s neither included in the 'allowed_partner_ids' group nor set as the 'default_partner_id'.

21 changes: 21 additions & 0 deletions helpdesk_mgmt_team_customer/models/helpdesk_ticket_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# © 2025 Solvos Consultoría Informática (<http://www.solvos.es>)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import api, fields, models


class HelpdeskTicketTeam(models.Model):
_inherit = "helpdesk.ticket.team"

default_partner_id = fields.Many2one(
comodel_name="res.partner",
)
is_unique_partner = fields.Boolean()
allowed_partner_ids = fields.Many2many(
comodel_name="res.partner",
)

@api.onchange("default_partner_id")
def _onchange_default_partner_id(self):
for record in self.filtered(lambda x: not x.default_partner_id):
record.is_unique_partner = False
3 changes: 3 additions & 0 deletions helpdesk_mgmt_team_customer/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions helpdesk_mgmt_team_customer/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Solvos](https://www.solvos.es):
- Carlos García \<<carlos.garcia@solvos.es>\>
- Dante Pereyra \<<dante.pereyra@solvos.es>\>
102 changes: 102 additions & 0 deletions helpdesk_mgmt_team_customer/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
Overview
========

Allows dynamic control over which contact (partner_id) on ticket,
based on the configuration of the assigned Helpdesk Team (team_id). The logic works as follows:
- If the team has a default contact, it will fill the contact field with that value.
- If the team has a unique contact, only that contact will be available.
- If the team has a list of allowed contacts, only those contacts will be available.
- If the team has no restrictions, all contacts will be available.

Use Case
=================

This module is designed for organizations that structure their Helpdesk teams
around customers, rather than functional support areas.

A typical use case is a software development or services company where:

- Each customer has a dedicated Helpdesk Team.
- Developers and support agents are assigned to customer-specific teams.
- The Helpdesk dashboard is used to track workload per customer
(e.g. "Customer X – 4 open tickets").

In this setup, every ticket created for a given team is implicitly related
to a specific customer. However, in standard Odoo, both fields must still be
manually selected:

- Team: Customer X
- Customer: Customer X

This repetition is error-prone and slows down ticket creation.

Module Purpose
==============

The goal of this module is to streamline ticket creation and prevent
inconsistent data by linking Helpdesk Teams to one or more allowed customers.

Depending on the team configuration, the module can:

- Automatically set a default customer when a team is selected.
- Restrict the customer field to a single allowed customer.
- Restrict the customer field to a predefined list of customers.

As a result:

- Ticket creation is faster.
- The risk of assigning a ticket to the wrong customer is reduced.
- The Helpdesk dashboard remains consistently grouped by customer.

Design Rationale
================

Why the restriction goes from Team to Customer
---------------------------------------------

Unlike more common setups where customers are restricted to specific teams,
this module addresses scenarios where:

- Teams represent customer contexts.
- Agents frequently switch between customer-dedicated teams.
- Correct customer assignment is critical for reporting, dashboards,
and contractual scope control.

For these scenarios, enforcing customer consistency at the team level
is both intentional and required.

Why a server-side constraint is required
---------------------------------------

The dynamic domain on the customer field is intended as user guidance,
but it is not sufficient to guarantee data consistency.

In standard Odoo behavior, many2one fields allow on-the-fly record creation.
For example, an agent may type a new customer name and press Enter, creating
a new partner that bypasses the UI domain restriction.

For this reason, a server-side constraint is required to ensure that,
when a Helpdesk Team defines an explicit list of allowed customers,
no ticket can be saved with a customer outside that list.

The constraint does not prevent customer creation; it only enforces
the team-to-customer consistency rule at persistence time.

Why Record Rules are not used
----------------------------

This module does not aim to restrict global access to partners.

Partner availability is contextual and depends on the Helpdesk Team selected
on each ticket. The same user may work with multiple customer-dedicated teams
during the same day.

Record Rules are evaluated at user or group level and are therefore not
well suited for per-record, team-dependent restrictions.

For this reason, the module uses:
- a dynamic domain for user guidance
- a server-side constraint for data consistency

This keeps the implementation simple, predictable, and aligned with
Odoo’s standard interaction patterns.
Loading