diff --git a/mail_edit/README.rst b/mail_edit/README.rst index 18f2126b..2ff511dd 100644 --- a/mail_edit/README.rst +++ b/mail_edit/README.rst @@ -62,6 +62,7 @@ Contributors * Tom Blauwendraat * George Daramouskas * Holger Brunn +* Giovanni Francesco Capalbo Maintainer ---------- diff --git a/mail_edit/__init__.py b/mail_edit/__init__.py index 94469cde..4582ed24 100644 --- a/mail_edit/__init__.py +++ b/mail_edit/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2016 Sunflower IT (http://sunflowerweb.nl) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/mail_edit/__openerp__.py b/mail_edit/__openerp__.py index 9adaca47..a36d8313 100644 --- a/mail_edit/__openerp__.py +++ b/mail_edit/__openerp__.py @@ -5,13 +5,13 @@ { "name": "Message Edit", "summary": "Adds an option to edit mail to different partners", - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", "category": "Social Network", "website": "https://sunflowerweb.nl", "author": "Sunflower IT, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, - "installable": False, + "installable": True, "depends": [ "mail", "web", diff --git a/mail_edit/models/compose_message.py b/mail_edit/models/compose_message.py index 055d02ad..df214a78 100644 --- a/mail_edit/models/compose_message.py +++ b/mail_edit/models/compose_message.py @@ -46,6 +46,7 @@ class MailMessage(models.Model): messages, message_tree) for message_dict in messages: # Check if current user is a superuser - if self.env.user.has_group('mail_edit.group_mail_edit_superuser'): - message_dict['is_superuser'] = True + superuser_group = 'mail_edit.group_mail_edit_superuser' + message_dict.update( + {'is_superuser' : self.env.user.has_group(superuser_group)}) return res diff --git a/mail_edit/static/src/js/mail_edit.js b/mail_edit/static/src/js/mail_edit.js index db0a1b14..f830dc30 100644 --- a/mail_edit/static/src/js/mail_edit.js +++ b/mail_edit/static/src/js/mail_edit.js @@ -1,50 +1,40 @@ /* © 2014-2017 Sunflower IT */ +odoo.define('mail_edit.thread', function(require) { -"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); - this.$('.oe_delete').on('click', this.on_message_delete); - }, - - on_message_edit: function () { - var context = {}; - - // save the widget object in a var. - var self = this; + "use strict"; - // Get the action data - var do_action = this.do_action; + var thread = require('mail.ChatThread'); - 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 - var parent = self.getParent().getParent().getParent().getParent() - if (typeof parent.model !== "undefined"){ - parent.reload(); - } - }, - }); - }); - } - }); - - instance.mail.MessageCommon.include({ - init: function (parent, datasets, options) { - this._super(parent, datasets, options); - this.is_superuser = datasets.is_superuser || false; - } + thread.include({ + init: function(){ + this._super.apply(this, arguments); + this.events['click .o_edit'] = function (event) { + var context = {}; + // save the widget object in a var. + var self = this; + // Get the action data + var message_id = $(event.currentTarget).data('message-id'); + var do_action = this.do_action; + this.rpc("/web/action/load", { + "action_id": "mail_edit.mail_edit_action", + }) + .done(function(action) { + action.res_id = message_id; + action.flags = { + action_buttons: true, + }; + action.context = context; + do_action(action, { + on_close: function () { + // reload view + var parent = self.getParent().getParent().getParent() + 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 index 5e25c490..0c1fe5c6 100644 --- a/mail_edit/static/src/xml/mail_edit.xml +++ b/mail_edit/static/src/xml/mail_edit.xml @@ -1,16 +1,15 @@ diff --git a/mail_edit/views/compose_message.xml b/mail_edit/views/compose_message.xml index 87779a6f..c7f470d9 100644 --- a/mail_edit/views/compose_message.xml +++ b/mail_edit/views/compose_message.xml @@ -12,7 +12,7 @@ - +