diff --git a/mail_message_copy_in_partner/README.rst b/mail_message_copy_in_partner/README.rst new file mode 100644 index 0000000..7f8ca63 --- /dev/null +++ b/mail_message_copy_in_partner/README.rst @@ -0,0 +1,52 @@ +==================== +mail_message_copy_in_partner +==================== + +Installation +============ +Use Odoo normal module installation procedure to install ``mail_message_copy_in_partner``. + + +Configuration +============= + +Nothing to do + + +Usage +===== +If module is installed, notes will never send email to partners not linked to internal users. + + +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 +------------ + +* 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. \ No newline at end of file diff --git a/mail_message_copy_in_partner/__init__.py b/mail_message_copy_in_partner/__init__.py new file mode 100644 index 0000000..e991714 --- /dev/null +++ b/mail_message_copy_in_partner/__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_message_copy_in_partner/__manifest__.py b/mail_message_copy_in_partner/__manifest__.py new file mode 100644 index 0000000..d449d0b --- /dev/null +++ b/mail_message_copy_in_partner/__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_message_copy_in_partner", + "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": "If current model has partner_id field, all messages will be copied in partner's chatter", + "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_message_copy_in_partner +================= +If current model has partner_id field, all messages will be copied in partner's chatter + + +Installation +============ + +Install ``mail_message_copy_in_partner``, 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_message_copy_in_partner/models/__init__.py b/mail_message_copy_in_partner/models/__init__.py new file mode 100644 index 0000000..db2c259 --- /dev/null +++ b/mail_message_copy_in_partner/models/__init__.py @@ -0,0 +1 @@ +from . import mail_thread \ No newline at end of file diff --git a/mail_message_copy_in_partner/models/mail_thread.py b/mail_message_copy_in_partner/models/mail_thread.py new file mode 100644 index 0000000..dd54ee7 --- /dev/null +++ b/mail_message_copy_in_partner/models/mail_thread.py @@ -0,0 +1,14 @@ +from odoo import api, models, _ + + +class MailThread(models.AbstractModel): + _inherit = 'mail.thread' + + @api.returns('mail.message', lambda value: value.id) + def message_post(self, body='', **kwargs): + #send message to related partner + if hasattr(self, 'partner_id') and self.partner_id: + msg = _('[%(object)s] %(body)s',object=self._get_html_link(), body=body) + self.partner_id.message_post(body=msg, **kwargs) + return super(MailThread, self).message_post(body=body, **kwargs) + \ No newline at end of file