Browse Source

[ADD] mail_edit v9

[FIX] #5124 field namechange in v9

[FIX] v9 chatter

[FIX] template fix

fix

[FIX] working version
pull/356/head
Giovanni Francesco Capalbo 5 years ago
parent
commit
cd3a48c6b7
  1. 1
      mail_edit/README.rst
  2. 1
      mail_edit/__init__.py
  3. 4
      mail_edit/__openerp__.py
  4. 5
      mail_edit/models/compose_message.py
  5. 80
      mail_edit/static/src/js/mail_edit.js
  6. 17
      mail_edit/static/src/xml/mail_edit.xml
  7. 2
      mail_edit/views/compose_message.xml

1
mail_edit/README.rst

@ -62,6 +62,7 @@ Contributors
* Tom Blauwendraat <tom@sunflowerweb.nl>
* George Daramouskas <gdaramouskas@therp.nl>
* Holger Brunn <hbrunn@therp.nl>
* Giovanni Francesco Capalbo <giovanni@therp.nl>
Maintainer
----------

1
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).

4
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",

5
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

80
mail_edit/static/src/js/mail_edit.js

@ -1,50 +1,40 @@
/* © 2014-2017 Sunflower IT <www.sunflowerweb.nl>*/
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();
}
},
});
});
};
},
});
};
});

17
mail_edit/static/src/xml/mail_edit.xml

@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<t t-extend="mail.thread.message">
<t t-jquery=".oe_msg_icons .oe_reply" t-operation="before">
<t t-if="widget.is_author or widget.is_superuser">
<span class="oe_edit">
<a title="Edit Mail" class="oe_e">&#038;</a>
<t t-extend="mail.ChatThread.Message">
<t t-jquery='p.o_mail_info>span>i:first-child' t-operation="after">
<span class="oe_edit">
<t t-if="is_author or is_superuser" >
<i title="Edit Mail" class="fa fa-pencil-square-o o_edit"
t-att-data-message-id="message.id">
</i>
</t>
</span>
<span class="oe_delete">
<a title="Delete" class="oe_e">[</a>
</span>
</t>
</t>
</t>
</template>

2
mail_edit/views/compose_message.xml

@ -12,7 +12,7 @@
<group>
<field name="subject" groups="mail_edit.group_mail_edit_editor,mail_edit.group_mail_edit_superuser"/>
<field name="date" readonly="1"/>
<field name="type" readonly="1"/>
<field name="message_type" readonly="1"/>
<field name="subtype_id" readonly="1"/>
</group>
<group>

Loading…
Cancel
Save