diff --git a/mail_edit/README.rst b/mail_edit/README.rst new file mode 100644 index 00000000..a611715a --- /dev/null +++ b/mail_edit/README.rst @@ -0,0 +1,77 @@ +.. 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 + +============ +Message Edit +============ + +This module extends the functionality of mail. You can edit message/messages +and move them to any model. + +Configuration +============= + +To configure this module: + +* Activate the 'Move mail message' or 'Edit mail message' permissions for a + user (the admin user has these rights by default) +* Objects that users are allowed to move messages to, can be + configured in Settings - Technical - Database structure - + Referenceable objects. + +Usage +===== + +To use this module, you need to: + +* Go to *Message* *Chatter* in any model, click the Edit (pen) Icon to open up + the 'Edit or Move' wizard. +* To edit, edit the Mail as necessary and click Save. +* To move, select the destination object and click Save. + +Known issues / Roadmap +====================== +* Does not reload after edit on messaging views. For this we needed to call + controller.reload(), a way to this would be to inherit the ActionManager and + call it from there. + +Bug Tracker +=========== + +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 +======= + +Images +------ + +* PICOL Icon Generator `here `__. + +Contributors +------------ + +* Dan Kiplangat +* Tom Blauwendraat + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/mail_edit/__init__.py b/mail_edit/__init__.py new file mode 100644 index 00000000..94469cde --- /dev/null +++ b/mail_edit/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Sunflower IT (http://sunflowerweb.nl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/mail_edit/__openerp__.py b/mail_edit/__openerp__.py new file mode 100644 index 00000000..19b36c10 --- /dev/null +++ b/mail_edit/__openerp__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# © 2016 Sunflower IT (http://sunflowerweb.nl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Message Edit", + "summary": "Adds an option to edit mail to different partners", + "version": "8.0.1.0.0", + "category": "Social Network", + "website": "https://sunflowerweb.nl", + "author": "Sunflower IT, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "mail", + "web", + ], + "data": [ + "security/mail_edit_security.xml", + "views/assets.xml", + "views/compose_message.xml", + "views/res_request_link.xml", + ], + "qweb": [ + "static/src/xml/mail_edit.xml", + ], +} diff --git a/mail_edit/i18n/nl.po b/mail_edit/i18n/nl.po new file mode 100644 index 00000000..360b879a --- /dev/null +++ b/mail_edit/i18n/nl.po @@ -0,0 +1,77 @@ +# Translation of Mail edit module. +# This file contains the translation of the following modules: +# * mail_edit +# +# Translators: +# Tom Blauwendraat , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-19 14:40+0000\n" +"PO-Revision-Date: 2017-08-18 16:51+0000\n" +"Last-Translator: Erwin van der Ploeg \n" +"Language-Team: Dutch (http://www.transifex.com/odoo/odoo-8/language/nl/)\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mail_edit +#: help:res.request.link,mail_edit:0 +msgid "Allow to move mails to this model." +msgstr "Sta toe om berichten naar dit model te verplaatsen." + +#. module: mail_edit +#: field:mail.message,destination_object_id:0 +msgid "Destination object" +msgstr "Doelobject" + +#. module: mail_edit +#. openerp-web +#: code:addons/mail_edit/static/src/xml/mail_edit.xml:7 +#, python-format +msgid "Edit Mail" +msgstr "Bericht wijzigen" + +#. module: mail_edit +#: model:res.groups,name:mail_edit.group_mail_edit_editor +msgid "Edit mail messages" +msgstr "Berichten wijzigen" + +#. module: mail_edit +#: model:ir.actions.act_window,name:mail_edit.mail_edit_action +msgid "Edit or Move Message" +msgstr "Wijzigen of verplaatsen van bericht" + +#. module: mail_edit +#: field:res.request.link,mail_edit:0 +msgid "Mail edit" +msgstr "Bericht wijzigen" + +#. module: mail_edit +#: model:res.groups,comment:mail_edit.group_mail_edit_editor +msgid "Members of this group are able to edit mail messages." +msgstr "Leden van deze groep mogen de inhoud van berichten wijzigen." + +#. module: mail_edit +#: model:res.groups,comment:mail_edit.group_mail_edit_mover +msgid "Members of this group are able to move mails." +msgstr "Leden van deze groep mogen berichten verplaatsen." + +#. module: mail_edit +#: model:ir.model,name:mail_edit.model_mail_message +#: view:mail.message:mail_edit.mail_edit_form +msgid "Message" +msgstr "Bericht" + +#. module: mail_edit +#: model:res.groups,name:mail_edit.group_mail_edit_mover +msgid "Move mail messages" +msgstr "Berichten verplaatsen" + +#. module: mail_edit +#: help:mail.message,destination_object_id:0 +msgid "Object where the message will be moved to" +msgstr "Object waar het bericht naartoe verplaatst zal worden" diff --git a/mail_edit/models/__init__.py b/mail_edit/models/__init__.py new file mode 100644 index 00000000..d958dab4 --- /dev/null +++ b/mail_edit/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 Sunflower IT (http://sunflowerweb.nl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import compose_message +from . import res_request_link diff --git a/mail_edit/models/compose_message.py b/mail_edit/models/compose_message.py new file mode 100644 index 00000000..4afb0f2b --- /dev/null +++ b/mail_edit/models/compose_message.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# © 2016 Sunflower IT (http://sunflowerweb.nl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import api, fields, models + + +class MailMessage(models.Model): + _inherit = "mail.message" + + @api.model + def _get_model_selection(self): + """Get allowed models and their names.""" + model_objs = self.env["res.request.link"].search( + [("mail_edit", "=", True)], + order="name") + 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.""" + # pylint: disable=api-one-deprecated + if self.destination_object_id: + self.model = self.destination_object_id._name + self.res_id = self.destination_object_id.id + + model_name = self.env["ir.model"].search([ + ("model", "=", self.model)]).name + display_name = self.destination_object_id.display_name + if model_name: + display_name = "%s %s" % (model_name, display_name) + + self.record_name = display_name + else: + self.model = self.res_id = self.record_name = False + + destination_object_id = fields.Reference( + _get_model_selection, + "Destination object", + help="Object where the message will be moved to") diff --git a/mail_edit/models/res_request_link.py b/mail_edit/models/res_request_link.py new file mode 100644 index 00000000..e8a42ac6 --- /dev/null +++ b/mail_edit/models/res_request_link.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# © 2016 Sunflower IT (http://sunflowerweb.nl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import fields, models + + +class ResRequestLink(models.Model): + _inherit = "res.request.link" + + mail_edit = fields.Boolean( + string="Mail move", + default=True, + index=True, + help="Allow to move mails to this model.") diff --git a/mail_edit/security/mail_edit_security.xml b/mail_edit/security/mail_edit_security.xml new file mode 100644 index 00000000..9e549384 --- /dev/null +++ b/mail_edit/security/mail_edit_security.xml @@ -0,0 +1,20 @@ + + + + + + Edit mail messages + Members of this group are able to edit mail messages. + + + + + + Move mail messages + Members of this group are able to move mails. + + + + + + diff --git a/mail_edit/static/description/icon.png b/mail_edit/static/description/icon.png new file mode 100644 index 00000000..b0ff417a Binary files /dev/null and b/mail_edit/static/description/icon.png differ diff --git a/mail_edit/static/src/css/mail_edit.css b/mail_edit/static/src/css/mail_edit.css new file mode 100644 index 00000000..751a6e09 --- /dev/null +++ b/mail_edit/static/src/css/mail_edit.css @@ -0,0 +1,9 @@ + +.openerp .oe_mail .oe_msg .oe_msg_icons .oe_edit:hover a { + color: #1FC0FF; + text-shadow: 0px 1px #184FC5, + 0px -1px #184FC5, + -1px 0px #184FC5, + 1px 0px #184FC5, + 0px 3px 3px rgba(0, 0, 0, 0.1); +} diff --git a/mail_edit/static/src/js/mail_edit.js b/mail_edit/static/src/js/mail_edit.js new file mode 100644 index 00000000..70b5c8cb --- /dev/null +++ b/mail_edit/static/src/js/mail_edit.js @@ -0,0 +1,44 @@ +/* © 2014-2017 Sunflower IT */ + +"use strict"; +openerp.mail_edit = function (instance) { + var _t = instance.web._t; + instance.mail.ThreadMessage.include({ + bind_events: function () { + this._super.apply(this, arguments); + this.$('.oe_edit').on('click', this.on_message_edit); + }, + + on_message_edit: function () { + var context = {}; + + // save the widget object in a var. + var self = this; + + // Get the action data + var do_action = this.do_action; + + this.rpc("/web/action/load", { + "action_id": "mail_edit.mail_edit_action", + }) + .done(function(action) { + action.res_id = self.id; + action.flags = { + action_buttons: true, + }; + action.context = context; + do_action(action, { + on_close: function () { + // reload view + //debugger; + var parent = self.getParent().getParent().getParent().getParent() + console.log(parent.model) + if (typeof parent.model !== "undefined"){ + parent.reload(); + } + }, + }); + }); + } + }); +}; diff --git a/mail_edit/static/src/xml/mail_edit.xml b/mail_edit/static/src/xml/mail_edit.xml new file mode 100644 index 00000000..b647c74a --- /dev/null +++ b/mail_edit/static/src/xml/mail_edit.xml @@ -0,0 +1,11 @@ + + + diff --git a/mail_edit/views/assets.xml b/mail_edit/views/assets.xml new file mode 100644 index 00000000..c55d2d8d --- /dev/null +++ b/mail_edit/views/assets.xml @@ -0,0 +1,17 @@ + + + + + +