Metadata-Version: 2.4
Name: odoo-addon-helpdesk_ticket_track_fetchmail_fix
Version: 16.0.1.0.0
Summary: Fixes an AttributeError in helpdesk_mgmt's tracking override that silently rolls back helpdesk tickets created from incoming email.
Home-page: https://gitlab.com/somitcoop/erp-research/odoo-helpdesk
Author: Som Connexió SCCL
License: AGPL-3
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 16.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Requires-Python: >=3.10
Requires-Dist: odoo-addon-helpdesk_mgmt<16.1dev,>=16.0dev
Requires-Dist: odoo<16.1dev,>=16.0a
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: home-page
Dynamic: license
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

#####################################
 Helpdesk Ticket Track Fetchmail Fix
#####################################

``helpdesk_mgmt`` overrides ``_message_track_post_template`` to force a
"stage changed" notification on tickets created from the mail gateway:

.. code::

   def _message_track_post_template(self, changes):
       if (
           self._context.get("default_fetchmail_server_id")
           and self._name == "helpdesk.ticket"
       ):
           changes.append("stage_id")
       return super()._message_track_post_template(changes)

This assumes ``changes`` is always a ``list``. Odoo core calls this
method with a ``set`` (or ``None``) when it runs from
``mail.thread._track_finalize``, the precommit hook triggered inside
``fetchmail.py``'s ``cr.commit()``. Neither has an ``.append`` method,
so this raises ``AttributeError: 'set' object has no attribute
'append'``.

Because this happens inside ``cr.commit()``, after the incoming email
has already been flagged ``\\Seen`` on the mail server but before the
new ticket is committed to the database, the ticket creation is rolled
back while the email is never fetched again (the IMAP search only looks
for ``UNSEEN`` messages). The email is effectively lost, without any
error visible to the end user.

This module fixes it by normalizing ``changes`` to a list before it
reaches ``helpdesk_mgmt``'s override, without altering the intended
behaviour (forcing the stage-change notification for tickets created by
email).

**Table of contents**

.. contents::
   :local:

***************
 Configuration
***************

No configuration needed for this module.

*******
 Usage
*******

No user-facing changes. Just install this module alongside
``helpdesk_mgmt`` to prevent tickets created from incoming email from
being silently lost.

************************
 Known issues / Roadmap
************************

If a future version of ``helpdesk_mgmt`` fixes this upstream, this
module becomes a no-op and can be removed. Version 17 of
``helpdesk_mgmt`` does not have this issue because there is no
overriding of ``_message_track_post_template`` in that version.

*************
 Bug Tracker
*************

Bugs are tracked on `GitLab Issues
<https://gitlab.com/somitcoop/erp-research/odoo-helpdesk/-/issues>`_. In
case of trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback.

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

*********
 Credits
*********

Authors
=======

-  Som Connexio SCCL

Contributors
============

-  `Som Connexio SCCL <https://somconnexio.coop>`_:

      -  Gerard Funosas <gerard.funosas@somconnexio.coop>

-  `SomIT SCCL <https://somit.coop>`_:

      -  Álvaro García <alvaro.garcia@somit.coop>

Maintainers
===========

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization
whose mission is to support the collaborative development of Odoo
features and promote its widespread use.

You are welcome to contribute. To learn how please visit
https://odoo-community.org/page/Contribute.
