diff --git a/mail_forward/README.rst b/mail_forward/README.rst index 523dbcf1..83f998b7 100644 --- a/mail_forward/README.rst +++ b/mail_forward/README.rst @@ -9,31 +9,30 @@ Message forward This module was written to extend the functionality of mails to support forwarding them to another contact or database object. -* **To another object of the database:** - * All its followers are notified according to their settings. -* **To other contacts:** - * They recieve the forwarded message according to the usual notification - rules of Odoo. - -Installation -============ - -When installed, this module allows forwarding to the following database -objects: - -* ``crm.lead`` -* ``crm.meeting`` -* ``crm.phonecall`` -* ``mail.group`` -* ``note.note`` -* ``product.product`` -* ``project.project`` -* ``project.task`` -* ``res.partner`` -* ``sale.order`` - -Of course, if some of those are not available in your database, they will be -hidden until you install the module that adds them. +* **To another object of the database:** All its followers are notified + according to their settings. + +* **To other contacts:** They recieve the forwarded message according to the + usual notification rules of Odoo. + +Configuration +============= + +When installed, this module allows forwarding to a limited selection of +database models, that will get automatically updated when you install other +modules. + +This list can be customized by a user that has *Technical Features* permission. +To do it: + +* Go to *Settings > Technical > Database Structure > Referenceable Models*. + +* Any model there with *Mail forward target* enabled will appear in the list of + models that can get forwarded messages. + + * If you want to *remove* a model from the list, it's usually better to just + *disable* its check box instead of deleting it, because that record might + be used by other modules. Usage ===== @@ -75,7 +74,7 @@ Bugs are tracked on `GitHub 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 `here -`_. +`_. Credits diff --git a/mail_forward/__init__.py b/mail_forward/__init__.py index 9611dac3..04742c5f 100644 --- a/mail_forward/__init__.py +++ b/mail_forward/__init__.py @@ -2,4 +2,4 @@ # © 2014-2015 Grupo ESOC # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from .wizard import mail_forward +from . import models, wizard diff --git a/mail_forward/__openerp__.py b/mail_forward/__openerp__.py index 711ae210..f1a580c5 100644 --- a/mail_forward/__openerp__.py +++ b/mail_forward/__openerp__.py @@ -5,9 +5,9 @@ { "name": "Message Forward", "summary": "Add option to forward messages", - "version": "8.0.6.0.0", + "version": "8.0.7.0.0", "category": "Social Network", - "website": "http://www.grupoesoc.es, https://odoo-community.org/", + "website": "https://odoo-community.org/", "author": "Grupo ESOC, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, @@ -17,8 +17,9 @@ "web", ], "data": [ - "wizard/mail_forward.xml", "views/assets.xml", + "views/res_request_link.xml", + "wizard/mail_forward.xml", ], "qweb": [ "static/src/xml/mail_forward.xml", diff --git a/mail_forward/models.py b/mail_forward/models.py new file mode 100644 index 00000000..8cc4fd6f --- /dev/null +++ b/mail_forward/models.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# © 2014-2015 Grupo ESOC +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import fields, models + + +class IrModel(models.Model): + _inherit = "res.request.link" + + mail_forward_target = fields.Boolean( + default=True, + index=True, + help="Allow to forward mails to this model.") diff --git a/mail_forward/views/res_request_link.xml b/mail_forward/views/res_request_link.xml new file mode 100644 index 00000000..e6fd5ffb --- /dev/null +++ b/mail_forward/views/res_request_link.xml @@ -0,0 +1,32 @@ + + + + + + + + + Add option to forward mails + res.request.link + + + + + + + + + + Add option to forward mails + res.request.link + + + + + + + + + + diff --git a/mail_forward/wizard/__init__.py b/mail_forward/wizard/__init__.py index e69de29b..ec73f325 100644 --- a/mail_forward/wizard/__init__.py +++ b/mail_forward/wizard/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2014-2015 Grupo ESOC +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import mail_forward diff --git a/mail_forward/wizard/mail_forward.py b/mail_forward/wizard/mail_forward.py index d930e962..2f16dae5 100644 --- a/mail_forward/wizard/mail_forward.py +++ b/mail_forward/wizard/mail_forward.py @@ -11,23 +11,9 @@ class MailForwardComposeMessage(models.TransientModel): It duplicates the message and optionally attaches it to another object of the database and sends it to another recipients than the original one. """ - _name = "mail_forward.compose.message" _inherits = {"mail.compose.message": "original_wizard_id"} - _models = [ - "crm.lead", - "crm.meeting", - "crm.phonecall", - "mail.group", - "note.note", - "product.product", - "project.project", - "project.task", - "res.partner", - "sale.order", - ] - @api.model def default_get(self, fields): """Fix default values. @@ -39,7 +25,6 @@ class MailForwardComposeMessage(models.TransientModel): This method fixes that by getting it from the context if available. """ - result = self.original_wizard_id.default_get(fields) if "subject" in result and "default_subject" in self.env.context: @@ -49,23 +34,16 @@ class MailForwardComposeMessage(models.TransientModel): @api.model def models(self): - """Get allowed models and their names. - - It searches for the models on the database, so if modules are not - installed, models will not be shown. - """ - - model_objs = self.env["ir.model"].search( - [("model", "in", self.env.context.get("model_list", - self._models))], + """Get allowed models and their names.""" + model_objs = self.env["res.request.link"].search( + [("mail_forward_target", "=", True)], order="name") - return [(m.model, m.name) for m in model_objs] + return [(m.object, m.name) for m in model_objs] @api.one @api.onchange("destination_object_id") def change_destination_object(self): """Update some fields for the new message.""" - if self.destination_object_id: self.model = self.destination_object_id._name self.res_id = self.destination_object_id.id @@ -84,7 +62,6 @@ class MailForwardComposeMessage(models.TransientModel): @api.one def send_mail(self): """Send mail and execute the attachment relocation if needed.""" - # Let the original wizard do de hard work result = self.original_wizard_id.send_mail()