From 1e762d8c475b0ff6e514c40cd134fd5aabaa40f2 Mon Sep 17 00:00:00 2001 From: clementthomas Date: Thu, 27 Jun 2024 10:58:42 +0200 Subject: [PATCH] [NEW] mail_prevent_send_note_to_external --- mail_prevent_send_note_to_external/README.rst | 72 +++++++++++++++ .../__init__.py | 4 + .../__manifest__.py | 88 +++++++++++++++++++ .../models/__init__.py | 1 + .../models/mail_thread.py | 19 ++++ 5 files changed, 184 insertions(+) create mode 100644 mail_prevent_send_note_to_external/README.rst create mode 100644 mail_prevent_send_note_to_external/__init__.py create mode 100644 mail_prevent_send_note_to_external/__manifest__.py create mode 100644 mail_prevent_send_note_to_external/models/__init__.py create mode 100644 mail_prevent_send_note_to_external/models/mail_thread.py diff --git a/mail_prevent_send_note_to_external/README.rst b/mail_prevent_send_note_to_external/README.rst new file mode 100644 index 0000000..3a8268d --- /dev/null +++ b/mail_prevent_send_note_to_external/README.rst @@ -0,0 +1,72 @@ +==================== +mail_activity_plan +==================== + +Installation +============ +Use Odoo normal module installation procedure to install ``mail_activity_plan``. + + +Configuration +============= + +To create activities plans, go to Settings > Technical > Discuss > Activity plans : + +Provice a name + +Add activity templates : + +Select an activity type, write a summary. Optionnaly assigne to a user and write a note. + +A plan can be related to many activity templates + +A activity template can be related to only one plan + +A activity template is related to only one activity type + + +Usage +===== +Once your plan is configured, you can define a server-action to launch automatically the activities for a choose model + +Go to Settings > Technical > Actions > Server Actions + +Provide a name, select a model, select action "[generate_activities]", select a plan. + +Once your new server action is configured, go to an instance of the chosen model, +click on the server action to generate automatically the activities of the plan. + +If nobody is assigned to a activity, the current user will be automatically assigned. + +Known issues / Roadmap +====================== + +None yet. + +Bug Tracker +=========== + +Bugs are tracked on `our issues website `_. 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. + +Credits +======= + +Contributors +------------ + +* Laetitia Da Costa (https://github.com/LaetitiaElabore) + +Funders +------- + +The development of this module has been financially supported by: +* Elabore (https://elabore.coop) + + +Maintainer +---------- + +This module is maintained by Elabore. \ No newline at end of file diff --git a/mail_prevent_send_note_to_external/__init__.py b/mail_prevent_send_note_to_external/__init__.py new file mode 100644 index 0000000..e991714 --- /dev/null +++ b/mail_prevent_send_note_to_external/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models \ No newline at end of file diff --git a/mail_prevent_send_note_to_external/__manifest__.py b/mail_prevent_send_note_to_external/__manifest__.py new file mode 100644 index 0000000..923f07d --- /dev/null +++ b/mail_prevent_send_note_to_external/__manifest__.py @@ -0,0 +1,88 @@ +# Copyright 2022 Laetitia Élabore (Elabore) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "mail_prevent_send_note_to_external", + "version": "16.0.1.0.0", + "author": "Elabore", + "website": "https://github.com/elabore-coop/ux-tools", + "maintainer": "Clément", + "license": "AGPL-3", + "category": "Tools", + "summary": "Prevent chatter note to send email to external partner", + "description": """ + :image: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +================= +mail_prevent_send_note_to_external +================= + +Prevent chatter note to send email to external partner + +Installation +============ + +Install ``mail_prevent_send_note_to_external``, all dependencies will be installed by default. + +Known issues / Roadmap +====================== + +None yet. + +Bug Tracker +=========== + +Bugs are tracked on `our issues website +`_. 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. + +Credits +======= + +Images +------ + +* Elabore: `Icon `_. + +Contributors +------------ + +* Clément Thomas + +Funders +------- + +The development of this module has been financially supported by: +* Elabore (https://elabore.coop) + + +Maintainer +---------- +This module is maintained by Elabore. + +""", + # any module necessary for this one to work correctly + 'depends' : ['base_setup'], + "qweb": [ + # "static/src/xml/*.xml", + ], + "external_dependencies": { + "python": [], + }, + # always loaded + "data": [ + + ], + # only loaded in demonstration mode + "demo": [], + "js": [], + "css": [], + "installable": True, + # Install this module automatically if all dependency have been previously + # and independently installed. Used for synergetic or glue modules. + "auto_install": False, + "application": False, +} diff --git a/mail_prevent_send_note_to_external/models/__init__.py b/mail_prevent_send_note_to_external/models/__init__.py new file mode 100644 index 0000000..db2c259 --- /dev/null +++ b/mail_prevent_send_note_to_external/models/__init__.py @@ -0,0 +1 @@ +from . import mail_thread \ No newline at end of file diff --git a/mail_prevent_send_note_to_external/models/mail_thread.py b/mail_prevent_send_note_to_external/models/mail_thread.py new file mode 100644 index 0000000..6ea55d3 --- /dev/null +++ b/mail_prevent_send_note_to_external/models/mail_thread.py @@ -0,0 +1,19 @@ +from odoo import api, models, _ + + +class MailThread(models.AbstractModel): + _inherit = 'mail.thread' + + @api.returns('mail.message', lambda value: value.id) + def message_post(self, **kwargs): + #check subtype_xmlid and partner_ids, and remove external partners if subtype is "note" + if kwargs.get("subtype_xmlid") == 'mail.mt_note' and "partner_ids" in kwargs: + new_partner_ids = [] + for partner_id in kwargs["partner_ids"]: + user = self.env["res.users"].search([('partner_id','=',partner_id)]) + if user.active and user.has_group('base.group_user'): + new_partner_ids.append(partner_id) + kwargs["partner_ids"] = new_partner_ids + + message = super(MailThread, self).message_post(**kwargs) + return message \ No newline at end of file