Files
Odoo-Modules/fusion_helpdesk/models/res_config_settings.py
gsinghpal 15470426eb refactor(fusion_helpdesk): owner contact is a res.partner, not two text fields
Smaller UX simplification on the client side: the owner is already a
contact in entech's address book, so picking one is faster + safer than
re-typing their email and name (and avoids typos creeping into the
approval-email To: header).

What changed:
- Entech settings: drop fhd_owner_email + fhd_owner_name char fields;
  add fhd_owner_partner_id Many2one to res.partner exposed in the
  same "Owner Approval" block as a single partner selector. Quick-create
  + create-and-edit kept enabled so admins can spin up a new partner
  inline if the owner isn't already in the system.
- controllers/main.py::_read_config: derives owner_email + owner_name
  from the selected partner via the new _resolve_owner_contact helper.
  Missing / dangling partner id → blank email + name → central simply
  won't see the keys and the Engage button stays disabled (correct
  "not configured" behaviour).
- Nexa side: ZERO changes. Still receives owner_email + owner_name
  strings on the ticket payload, still upserts client_key.owner_email/
  name. The partner abstraction stops at the entech boundary.
- migrations/19.0.2.1.0/post-migration.py auto-resolves the legacy
  fusion_helpdesk.owner_email ICP value to an existing res.partner
  (lowest-id match on lowercased email), writes the new
  fusion_helpdesk.owner_partner_id key, and deletes the obsolete
  owner_email + owner_name ICP rows so a future reader doesn't trip
  over stale config.

Verified live on entech: kris@enplating.ca → res.partner #2308 ("Kris
Pathinather"), legacy keys purged, controller._resolve_owner_contact
returns the expected (email, name). The piggyback payload is unchanged
so existing client_key sync continues to work without a central
redeploy.

Bumps fusion_helpdesk to 19.0.2.1.0. fusion_helpdesk_central stays at
19.0.2.0.0 (no central-side changes required).
2026-05-27 13:21:08 -04:00

71 lines
3.1 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1
"""Configuration for the Fusion Helpdesk Reporter.
Stores the central Odoo Helpdesk endpoint that submissions are
forwarded to. Defaults point at erp.nexasystems.ca / nexamain;
each client deployment can override per system parameter.
"""
from odoo import api, fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
fhd_remote_url = fields.Char(
string='Helpdesk Remote URL',
config_parameter='fusion_helpdesk.remote_url',
help='Base URL of the central Odoo running the Helpdesk app, '
'e.g. https://erp.nexasystems.ca',
)
fhd_remote_db = fields.Char(
string='Helpdesk Remote DB',
config_parameter='fusion_helpdesk.remote_db',
help='Database name on the remote Odoo (e.g. nexamain).',
)
fhd_remote_login = fields.Char(
string='Helpdesk Remote Login',
config_parameter='fusion_helpdesk.remote_login',
help='Service-account login on the remote Odoo. Needs create '
'rights on helpdesk.ticket and ir.attachment.',
)
fhd_remote_password = fields.Char(
string='Helpdesk Remote Password / API Key',
config_parameter='fusion_helpdesk.remote_password',
help='Service-account password or API key. Stored in '
'ir.config_parameter — restrict read access if needed.',
)
fhd_remote_team_id = fields.Integer(
string='Helpdesk Team ID',
config_parameter='fusion_helpdesk.remote_team_id',
help='Optional. ID of the helpdesk.team on the remote that '
'should own all incoming tickets. Leave blank to use '
'the remote default routing.',
)
fhd_client_label = fields.Char(
string='Client Label (auto-prepended to subject)',
config_parameter='fusion_helpdesk.client_label',
help='Short tag prefixed onto the ticket subject so support '
'can tell which client deployment a ticket came from. '
'e.g. "ENTECH""[ENTECH] My subject"',
)
# Owner contact for the central engagement / approval flow. Picked
# from the existing res.partner — the owner is already a contact in
# the system, no point retyping their email and name. Email + name
# are derived from the partner at submit-time and piggybacked on
# every ticket payload (see controllers/main.py::submit) so central
# always has the latest contact without a dedicated sync endpoint.
# Leaving the partner blank disables the "Request Owner Approval"
# button on the central side for this client.
fhd_owner_partner_id = fields.Many2one(
'res.partner',
string='Owner Contact',
config_parameter='fusion_helpdesk.owner_partner_id',
help='The real decision-maker at your company — the person who '
'can approve feature requests or bug-fix scope. Used when '
'central support hits a ticket that needs sign-off. '
'Email and name are taken from the selected contact. '
'Leave blank if your deployment doesn\'t require approvals.',
)