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
93 changes: 93 additions & 0 deletions fastapi_mail_tracking/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
=====================
Fastapi Mail Tracking
=====================

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

.. |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/licence-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-OCA%2Frest--framework-lightgray.png?logo=github
:target: https://github.com/OCA/rest-framework/tree/18.0/fastapi_mail_tracking
:alt: OCA/rest-framework
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-fastapi_mail_tracking
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module sets the author of tracking notifications messages to the
FastAPI authenticated partner.

It also adds a message subtype corresponding to the current FastAPI
endpoint to link the changes to the endpoint.

**Table of contents**

.. contents::
:local:

Usage
=====

Activation is automatic.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/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/OCA/rest-framework/issues/new?body=module:%20fastapi_mail_tracking%0Aversion:%2018.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
-------

* Akretion

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

- Florian Mounier florian.mounier@akretion.com

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.

.. |maintainer-paradoxxxzero| image:: https://github.com/paradoxxxzero.png?size=40px
:target: https://github.com/paradoxxxzero
:alt: paradoxxxzero

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-paradoxxxzero|

This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/18.0/fastapi_mail_tracking>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions fastapi_mail_tracking/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions fastapi_mail_tracking/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2026 Akretion (http://www.akretion.com).
# @author Florian Mounier <florian.mounier@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Fastapi Mail Tracking",
"version": "18.0.1.0.0",
"author": "Akretion, Odoo Community Association (OCA)",
"summary": "Use authenticated partner as author of changes in the chatter "
"and use an endpoint subtype.",
"depends": [
"mail",
"fastapi_endpoint_context",
],
"website": "https://github.com/OCA/rest-framework",
"data": [],
"maintainers": ["paradoxxxzero"],
"installable": True,
"license": "AGPL-3",
}
1 change: 1 addition & 0 deletions fastapi_mail_tracking/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mail_thread
53 changes: 53 additions & 0 deletions fastapi_mail_tracking/models/mail_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2026 Akretion (http://www.akretion.com).
# @author Florian Mounier <florian.mounier@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class MailThread(models.AbstractModel):
_inherit = "mail.thread"

def _message_compute_author(
self, author_id=None, email_from=None, raise_on_email=True
):
# Use fastapi authenticated partner as author
if self.env.context.get("authenticated_partner_id"):
author_id = self.env.context["authenticated_partner_id"]

author_id, email_from = super()._message_compute_author(
author_id, email_from, raise_on_email
)
return author_id, email_from

def _get_tracking_fastapi_subtype_description(self):
endpoint = (
self.env["fastapi.endpoint"]
.sudo()
.browse(self.env.context["fastapi_endpoint_id"])
)

return f"Via {endpoint.name}"

def _track_subtype(self, init_values):
if self.env.context.get("fastapi_app"):
# Get or create the subtype for the FastAPI app
subtype = (
self.env["mail.message.subtype"]
.sudo()
.search([("name", "=", self.env.context["fastapi_app"])], limit=1)
)
if not subtype:
description = self._get_tracking_fastapi_subtype_description()
subtype = (
self.env["mail.message.subtype"]
.sudo()
.create(
{
"name": self.env.context["fastapi_app"],
"description": description,
}
)
)
return subtype
return super()._track_subtype(init_values)
3 changes: 3 additions & 0 deletions fastapi_mail_tracking/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions fastapi_mail_tracking/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Florian Mounier <florian.mounier@akretion.com>
5 changes: 5 additions & 0 deletions fastapi_mail_tracking/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module sets the author of tracking notifications messages to the FastAPI
authenticated partner.

It also adds a message subtype corresponding to the current FastAPI endpoint to link the
changes to the endpoint.
1 change: 1 addition & 0 deletions fastapi_mail_tracking/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Activation is automatic.
Loading
Loading