Skip to content
Extraits de code Groupes Projets
Valider b9bb571a rédigé par jordan's avatar jordan
Parcourir les fichiers

[init] initial commit

parent
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
============
Message Edit
============
This module extends the functionality of mail. You can edit message/mail.
**Table of contents**
.. contents::
:local:
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)
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 delete a message, click the trash icon, and do the confirmation.
Credits
=======
Authors
~~~~~~~
* Sunflower IT
* Le Filament
Contributors
~~~~~~~~~~~~
* `Sunflower IT <https://www.sunflowerweb.nl>`_:
* Dan Kiplangat <dan@sunflowerweb.nl>
* Tom Blauwendraat <tom@sunflowerweb.nl>
* `Therp BV <https://www.therp.nl>`_:
* George Daramouskas <gdaramouskas@therp.nl>
* Holger Brunn <hbrunn@therp.nl>
* `Le Filament <https://www.le-filamebt.com>`_:
* Jordan Coest <jordan@le-filament.com>
Other credits
~~~~~~~~~~~~~
Images
------
* PICOL Icon Generator `here <http://picol.org/picol_icon_generator>`__.
Maintainer
----------
.. image:: https://le-filament.com/img/logo-lefilament.png
:alt: Le Filament
:target: https://le-filament.com
This module is maintained by Le Filament
This module is part of the `OCA/social <https://github.com/OCA/social/tree/12.0-mig-mail-edit/mail_edit>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
# © 2022 Le Filament (<http://www.le-filament.com>)
# © 2016 Sunflower IT (http://sunflowerweb.nl)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
# © 2022 Le Filament (<http://www.le-filament.com>)
# © 2016 Sunflower IT (http://sunflowerweb.nl)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Message Edit",
"summary": "Edit and Delete mail messages",
"version": "12.0.2.0.0",
"category": "Social Network",
"website": "https://sunflowerweb.nl",
"author": "Sunflower IT, Odoo Community Association (OCA), Le Filament",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"mail",
"web",
],
"data": [
"security/mail_edit_security.xml",
"views/assets.xml",
"views/compose_message.xml",
],
"qweb": [
"static/src/xml/mail_edit.xml",
],
}
# © 2022 Le Filament (<http://www.le-filament.com>)
# © 2016 Sunflower IT (http://sunflowerweb.nl)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import compose_message
Fichier ajouté
Fichier ajouté
# © 2022 Le Filament (<http://www.le-filament.com>)
# © 2016 Sunflower IT (http://sunflowerweb.nl)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class MailMessage(models.Model):
_inherit = "mail.message"
@api.model
def _message_read_dict_postprocess(self, messages, message_tree):
res = super(MailMessage, self)._message_read_dict_postprocess(
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_editor'):
message_dict['can_edit'] = True
if self.env.user.has_group('mail_edit.group_mail_edit_superuser'):
message_dict['is_superuser'] = True
message_dict['is_author'] = self.env.user.partner_id.id == \
message_dict['author_id'][0]
return res
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright
2022 Le Filament
2017 Sunflower IT
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record model="res.groups" id="group_mail_edit_editor" >
<field name="name">Modifier ses propres messages</field>
<field name="comment">Members of this group are able to edit its own mail messages.</field>
<field name="category_id" ref="base.module_category_hidden"/>
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
</record>
<record model="res.groups" id="group_mail_edit_superuser">
<field name="name">Modifier tous les messages</field>
<field name="comment">Members of this group are able to edit all mails messages.</field>
<field name="category_id" ref="base.module_category_hidden"/>
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
</record>
</odoo>
static/description/icon.png

2,36 ko

/* © 2014-2017 Sunflower IT <www.sunflowerweb.nl>
* © 2022 Le Filament (<http://www.le-filament.com>)
*/
odoo.define('mail_edit.mail_edit', function (require) {
"use strict";
var Message = require('mail.model.Message');
var Dialog = require('web.Dialog');
var ThreadWidget = require('mail.widget.Thread');
var session = require('web.session');
var SearchableThread = require('mail.model.SearchableThread');
var DocumentThread = require('mail.model.DocumentThread');
var core = require('web.core');
var _t = core._t;
SearchableThread.include({
init: function() {
this._super.apply(this, arguments);
this.isSearchableThread = true;
}
});
DocumentThread.include({
init: function() {
this._super.apply(this, arguments);
this.isDocumentThread = true;
},
mailEditRemoveMessage: function(messageID) {
this._messages = _.reject(this._messages, function (message) {
return message.getID() === messageID;
});
}
});
ThreadWidget.include({
events: _.defaults({
"click .o_mail_edit": "_onClickMessageEdit",
"click .o_mail_delete": "_onClickMessageDelete",
}, ThreadWidget.prototype.events),
_onClickMessageEdit: function(event) {
var self = this;
var do_action = self.do_action,
msg_id = $(event.currentTarget).data('message-id');
self._rpc({
route: "/web/action/load",
params: {
action_id: "mail_edit.mail_edit_action",
},
})
.done(function (action) {
action.res_id = msg_id;
return self.do_action(action, {
on_close: function () {
var message = self.call('mail_service', 'getMessage', msg_id);
self._rpc({
model: 'mail.message',
method: 'message_format',
args: [msg_id],
context: session.user_context,
})
.then(function (messagesData) {
var thread = self.call('mail_service', 'getThread', self._currentThreadID);
message._body = messagesData[0].body;
self.render(thread, {});
});
},
});
});
},
_onClickMessageDelete: function(event, options) {
var self = this;
event.stopPropagation();
event.preventDefault();
var msg_id = $(event.currentTarget).data('message-id');
Dialog.confirm(
self,
_t("Do you really want to delete this message?"), {
confirm_callback: function () {
return self._rpc({
model: 'mail.message',
method: 'unlink',
args: [[msg_id]],
})
.then(function() {
var thread = self.call('mail_service', 'getThread', self._currentThreadID);
if (thread.isSearchableThread) {
thread.removeMessage(msg_id);
self.removeMessageAndRender(msg_id, thread, {});
} else if (thread.isDocumentThread) {
thread.mailEditRemoveMessage(msg_id);
self.removeMessageAndRender(msg_id, thread, {});
}
});
},
}
);
}
});
Message.include({
init: function (parent, data) {
this._super.apply(this, arguments);
this.is_superuser = data.is_superuser || false;
this.is_author = data.is_author || false;
this.can_edit = data.can_edit || false;
this.message_type = data.message_type || false;
},
});
});
/* Copyright 2014-2015 Grupo ESOC <http://www.grupoesoc.es>
* © 2022 Le Filament (<http://www.le-filament.com>)
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
*/
.o_mail_thread .o_thread_message {
.o_mail_edit, .o_mail_delete {
cursor: pointer;
opacity: 0;
padding: 5px;
}
&:hover {
.o_mail_edit {
color: #1FC0FF;
opacity: 0.6;
&:hover {
opacity: 1;
}
}
.o_mail_delete {
color: red;
opacity: 0.6;
&:hover {
opacity: 1;
}
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright
2022 Le Filament
2017 Sunflower IT
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<template>
<t t-extend="mail.widget.Thread.Message">
<t t-jquery=".o_mail_info" t-operation="append">
<t t-if="((message.is_author and message.can_edit) or message.is_superuser) and message.message_type !== 'notification'">
<span class="o_thread_edit_icon">
<i class="fa o_thread_icon o_mail_edit fa-pencil" t-att-data-message-id="message.getID()" title="Edit Mail"/>
</span>
<span class="o_thread_delete_icon">
<i class="fa o_thread_icon o_mail_delete fa-trash" t-att-data-message-id="message.getID()" title="Delete Mail"/>
</span>
</t>
</t>
</t>
</template>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright
2022 Le Filament
2017 Sunflower IT
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<template id="assets_backend" name="Mail edit assets"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss"
href="/mail_edit/static/src/scss/mail_edit.scss"/>
<script type="text/javascript"
src="/mail_edit/static/src/js/mail_edit.js"/>
</xpath>
</template>
</odoo>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright
2022 Le Filament
2017 Sunflower IT
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="mail_edit_form" model="ir.ui.view">
<field name="name">Edit Email Form</field>
<field name="model">mail.message</field>
<field name="priority">50</field>
<field name="arch" type="xml">
<form string="Message" create="false">
<sheet>
<field name="body" groups="mail_edit.group_mail_edit_editor,mail_edit.group_mail_edit_superuser"/>
<footer>
<button string="Save" special="save" class="btn-primary"/>
<button string="Discard" class="btn-secondary" special="cancel" />
</footer>
</sheet>
</form>
</field>
</record>
<record id="mail_edit_action" model="ir.actions.act_window">
<field name="name">Edit Message</field>
<field name="res_model">mail.message</field>
<field name="type">ir.actions.act_window</field>
<field name="view_id" ref="mail_edit_form"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter