Browse Source

[ADD]superuser - can edit or move anyones mails

pull/309/head
kiplangatdan 7 years ago
committed by Holger Brunn
parent
commit
3bf8d9abd4
  1. 10
      mail_edit/models/compose_message.py
  2. 11
      mail_edit/security/mail_edit_security.xml
  3. 9
      mail_edit/static/src/css/mail_edit.css
  4. 7
      mail_edit/static/src/js/mail_edit.js
  5. 2
      mail_edit/static/src/xml/mail_edit.xml
  6. 6
      mail_edit/views/compose_message.xml

10
mail_edit/models/compose_message.py

@ -39,3 +39,13 @@ class MailMessage(models.Model):
_get_model_selection,
"Destination object",
help="Object where the message will be moved to")
@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_superuser'):
message_dict['is_superuser'] = True
return res

11
mail_edit/security/mail_edit_security.xml

@ -3,18 +3,25 @@
<data noupdate="1">
<record model="res.groups" id="group_mail_edit_editor" >
<field name="name">Edit mail messages</field>
<field name="name">Edit own mail messages</field>
<field name="comment">Members of this group are able to edit mail messages.</field>
<field name="category_id" ref="base.module_category_hidden"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
<record model="res.groups" id="group_mail_edit_mover">
<field name="name">Move mail messages</field>
<field name="name">Move own mail messages</field>
<field name="comment">Members of this group are able to move mails.</field>
<field name="category_id" ref="base.module_category_hidden"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
<record model="res.groups" id="group_mail_edit_superuser">
<field name="name">Edit or Move anyone's mail messages</field>
<field name="comment">Members of this group are able to move or edit mails</field>
<field name="category_id" ref="base.module_category_hidden"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</openerp>

9
mail_edit/static/src/css/mail_edit.css

@ -7,3 +7,12 @@
1px 0px #184FC5,
0px 3px 3px rgba(0, 0, 0, 0.1);
}
.openerp .oe_mail .oe_msg .oe_msg_icons .oe_delete:hover a {
color: #ffa1a1;
text-shadow: 0px 1px #ff0000,
0px -1px #ff0000,
-1px 0px #ff0000,
1px 0px #ff0000,
0px 3px 3px rgba(0,0,0,0.1);
}

7
mail_edit/static/src/js/mail_edit.js

@ -40,4 +40,11 @@ openerp.mail_edit = function (instance) {
});
}
});
instance.mail.MessageCommon.include({
init: function (parent, datasets, options) {
this._super(parent, datasets, options);
this.is_superuser = datasets.is_superuser || false;
}
});
};

2
mail_edit/static/src/xml/mail_edit.xml

@ -3,7 +3,7 @@
<template>
<t t-extend="mail.thread.message">
<t t-jquery=".oe_msg_icons .oe_reply" t-operation="before">
<t t-if="widget.is_author">
<t t-if="widget.is_author or widget.is_superuser">
<span class="oe_edit">
<a title="Edit Mail" class="oe_e">&#038;</a>
</span>

6
mail_edit/views/compose_message.xml

@ -10,19 +10,19 @@
<sheet>
<group>
<group>
<field name="subject" groups="mail_edit.group_mail_edit_editor"/>
<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="subtype_id" readonly="1"/>
</group>
<group>
<field name="destination_object_id" required="1" groups="mail_edit.group_mail_edit_mover"/>
<field name="destination_object_id" required="1" groups="mail_edit.group_mail_edit_mover,mail_edit.group_mail_edit_superuser"/>
<field name="model" invisible="1"/>
<field name="res_id" invisible="1"/>
<field name="parent_id" readonly="1" />
</group>
</group>
<field name="body" groups="mail_edit.group_mail_edit_editor"/>
<field name="body" groups="mail_edit.group_mail_edit_editor,mail_edit.group_mail_edit_superuser"/>
</sheet>
</form>
</field>

Loading…
Cancel
Save