From b361f3248e90c4962a0c197a33ef3ac0969ddfb4 Mon Sep 17 00:00:00 2001 From: kiplangatdan Date: Wed, 14 Mar 2018 12:39:42 +0300 Subject: [PATCH] [8.0][ADD]mail_edit --- mail_edit/README.rst | 77 ++++++++++++++++++++++ mail_edit/__init__.py | 5 ++ mail_edit/__openerp__.py | 28 ++++++++ mail_edit/i18n/nl.po | 77 ++++++++++++++++++++++ mail_edit/models/__init__.py | 6 ++ mail_edit/models/compose_message.py | 41 ++++++++++++ mail_edit/models/res_request_link.py | 15 +++++ mail_edit/security/mail_edit_security.xml | 20 ++++++ mail_edit/static/description/icon.png | Bin 0 -> 2417 bytes mail_edit/static/src/css/mail_edit.css | 9 +++ mail_edit/static/src/js/mail_edit.js | 44 +++++++++++++ mail_edit/static/src/xml/mail_edit.xml | 11 ++++ mail_edit/views/assets.xml | 17 +++++ mail_edit/views/compose_message.xml | 42 ++++++++++++ mail_edit/views/res_request_link.xml | 29 ++++++++ 15 files changed, 421 insertions(+) create mode 100644 mail_edit/README.rst create mode 100644 mail_edit/__init__.py create mode 100644 mail_edit/__openerp__.py create mode 100644 mail_edit/i18n/nl.po create mode 100644 mail_edit/models/__init__.py create mode 100644 mail_edit/models/compose_message.py create mode 100644 mail_edit/models/res_request_link.py create mode 100644 mail_edit/security/mail_edit_security.xml create mode 100644 mail_edit/static/description/icon.png create mode 100644 mail_edit/static/src/css/mail_edit.css create mode 100644 mail_edit/static/src/js/mail_edit.js create mode 100644 mail_edit/static/src/xml/mail_edit.xml create mode 100644 mail_edit/views/assets.xml create mode 100644 mail_edit/views/compose_message.xml create mode 100644 mail_edit/views/res_request_link.xml 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 0000000000000000000000000000000000000000..b0ff417aad3c5eff8ca7008e1434e520edca5ba9 GIT binary patch literal 2417 zcmb_edpy%^AO10xIgV+q$f?kYZDQE#(B_;&ONpXvV?$xs91}AtheD~G(nEwEhj^4J zPg>!%vh3zcz!+qy??y_z4zzy{a&Bzy6)@#-k?)^CAUtI2Dt>&-GKDF#s@21^|2>0Bj4p{p6?xXh5mX4z?hI>xWHqA_%ZB$CFI(M6G|Ta+9tL z09#g_YzfC>M&^sWQwQwSJFFWE8m~KSDBvZPKQ!H@Cwh=*9UdlG~+rbQ|AzVnp;AY1@WSwbvK5NnQNQIUf65wZryTZ?pf^ zOVh2rla*<-9}Ahz>IXu!7W{m+AVon2zO9+ zbWsFlm1{Ym{OZ#lP*yR|K}=hJkh<#znij_#MCiQn>-{yJOlajwzV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{pUzI`1tgZf&HFz zN#7mqUlo$9q~&PrY`rF>C2nN>t+a+VdVW**xUhd~&sBpwwR)kPUFhM{AJy~IPT3DU zRK9%wi+lZ;Q5*M0_{S&#|C4pC~ciN(F_Q5}9bp~0mPe}^bs zYqv;xe`;N!KYQ*}e}P3w(+-o9ZT#X#?=d>M`|C{!kVjg5g(<^E<(&x^AB`F5>1Itf z8VIb;HU=FRj<(+;!xmve=XTc*IHAkIq&VzAuj(+)@Y5ku=kbcGyQ2MY`F8T;eE+$j z7Yf-+17xL-e4HwTE%j}aO`3#CO+Sd0j?A0s4$5sD6>`3F(Z d;A#KbOf*PYh9G67M=yZ004F;)+gc)-^AA$KSB?Mx literal 0 HcmV?d00001 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 @@ + + + + + +