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 mail_thread_post_access/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
=======================
Mail Thread Post Access
=======================

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

.. |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%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/17.0/mail_thread_post_access
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_thread_post_access
: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/social&target_branch=17.0
:alt: Try me on Runboat

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

This module allows to override ``_mail_post_access`` value for any model
that inherits from ``mail.thread``. This is useful when you want to
permit logging notes and sending messages to users that don't have write
access to the model.

**Table of contents**

.. contents::
:local:

Usage
=====

To override the default value of ``_mail_post_access`` for a model, do
the following:

1. Activate the developer mode.
2. Go to *Settings > Technical > Database Structure > Models*
3. Open the model you want to override the value for.
4. Modify the *Mail Post Access* value.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/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/social/issues/new?body=module:%20mail_thread_post_access%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
-------

* CorporateHub

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-alexey-pelykh| image:: https://github.com/alexey-pelykh.png?size=40px
:target: https://github.com/alexey-pelykh
:alt: alexey-pelykh

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

|maintainer-alexey-pelykh|

This module is part of the `OCA/social <https://github.com/OCA/social/tree/17.0/mail_thread_post_access>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions mail_thread_post_access/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
22 changes: 22 additions & 0 deletions mail_thread_post_access/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 CorporateHub
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Mail Thread Post Access",
"summary": (
"Allows to permit posting notes and messages to users that don't have"
" write access to the record"
),
"version": "17.0.1.0.0",
"category": "Productivity/Discuss",
"website": "https://github.com/OCA/social",
"author": "CorporateHub, Odoo Community Association (OCA)",
"maintainers": ["alexey-pelykh"],
"license": "AGPL-3",
"depends": [
"base",
"mail",
],
"data": [
"views/ir_model.xml",
],
}
3 changes: 3 additions & 0 deletions mail_thread_post_access/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import ir_model, mail_thread
17 changes: 17 additions & 0 deletions mail_thread_post_access/models/ir_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 CorporateHub
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class IrModel(models.Model):
_inherit = "ir.model"

mail_post_access = fields.Selection(
selection=[
("create", "Create"),
("read", "Read"),
("write", "Write"),
("unlink", "Delete"),
],
)
30 changes: 30 additions & 0 deletions mail_thread_post_access/models/mail_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2024 CorporateHub
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


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

@api.model
def _get_mail_message_access(self, res_ids, operation, model_name=None):
if operation in ["write", "unlink"]:
check_operation = "write"
elif operation == "create":
if model_name is None:
model_name = self._name
mail_post_access = self.env["ir.model"]._get(model_name).mail_post_access
if not mail_post_access:
mail_post_access = getattr(
self.env[model_name] if model_name else self,
"_mail_post_access",
"write",
)
if mail_post_access in ["create", "read", "write", "unlink"]:
check_operation = mail_post_access
else:
check_operation = "write"
else:
check_operation = operation
return check_operation
3 changes: 3 additions & 0 deletions mail_thread_post_access/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions mail_thread_post_access/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows to override ``_mail_post_access`` value for any model that inherits from ``mail.thread``. This is
useful when you want to permit logging notes and sending messages to users that don't have write access to the model.
6 changes: 6 additions & 0 deletions mail_thread_post_access/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To override the default value of ``_mail_post_access`` for a model, do the following:

1. Activate the developer mode.
2. Go to _Settings > Technical > Database Structure > Models_
3. Open the model you want to override the value for.
4. Modify the _Mail Post Access_ value.
Loading