[MERGE] [IMP] chatter: improved 'Log a note'
- the button is now only displayed for employee users. This is done by overriding the fields_view_get in mail.thread and adding options to the widget according to the groups the user belongs to. Indeed it is currently not possible to set widget options specific to some groups. Therefore an override of fields view get was necessary. - small layout improvements: Log a note -> Log an internal note, background color of notes updated. bzr revid: tde@openerp.com-20131125130455-u8517iyr4jgdgoqn
This commit is contained in:
commit
f148061b94
|
@ -23,6 +23,11 @@ import base64
|
|||
import datetime
|
||||
import dateutil
|
||||
import email
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json
|
||||
from lxml import etree
|
||||
import logging
|
||||
import pytz
|
||||
import time
|
||||
|
@ -306,6 +311,28 @@ class mail_thread(osv.AbstractModel):
|
|||
"be inserted in kanban views."),
|
||||
}
|
||||
|
||||
def _get_user_chatter_options(self, cr, uid, context=None):
|
||||
options = {
|
||||
'display_log_button': False
|
||||
}
|
||||
group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
|
||||
group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_user')[1]
|
||||
is_employee = group_user_id in [group.id for group in group_ids]
|
||||
if is_employee:
|
||||
options['display_log_button'] = True
|
||||
return options
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
res = super(mail_thread, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
|
||||
if view_type == 'form':
|
||||
doc = etree.XML(res['arch'])
|
||||
for node in doc.xpath("//field[@name='message_ids']"):
|
||||
options = json.loads(node.get('options', '{}'))
|
||||
options.update(self._get_user_chatter_options(cr, uid, context=context))
|
||||
node.set('options', json.dumps(options))
|
||||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
|
||||
#------------------------------------------------------
|
||||
# CRUD overrides for automatic subscription and logging
|
||||
#------------------------------------------------------
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
border: solid 1px rgba(0,0,0,0.03);
|
||||
}
|
||||
.openerp .oe_mail .oe_msg.oe_msg_nobody{
|
||||
background: #F8F8F8;
|
||||
background: #E4E4E4;
|
||||
}
|
||||
.openerp .oe_mail .oe_msg.oe_msg_notification{
|
||||
background: #F8F8F8;
|
||||
|
|
|
@ -1800,15 +1800,17 @@ openerp.mail = function (session) {
|
|||
'read_action': 'unread',
|
||||
'show_record_name': false,
|
||||
'show_compact_message': 1,
|
||||
'display_log_button' : true,
|
||||
}, this.node.params);
|
||||
|
||||
if (this.node.attrs.placeholder) {
|
||||
this.node.params.compose_placeholder = this.node.attrs.placeholder;
|
||||
}
|
||||
if (this.node.attrs.readonly) {
|
||||
this.node.params.readonly = this.node.attrs.readonly;
|
||||
}
|
||||
|
||||
if ('display_log_button' in this.options) {
|
||||
this.node.params.display_log_button = this.options.display_log_button;
|
||||
}
|
||||
this.domain = this.node.params && this.node.params.domain || [];
|
||||
|
||||
if (!this.ParentViewManager.is_action_enabled('edit')) {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<div class="oe_msg_attachment_list"></div>
|
||||
<button class="oe_post">
|
||||
<t t-if="!widget.is_log">Send</t>
|
||||
<t t-if="widget.is_log">Log a note</t>
|
||||
<t t-if="widget.is_log">Log an internal note</t>
|
||||
</button>
|
||||
<t t-call="mail.compose_message.add_attachment"/>
|
||||
</div>
|
||||
|
@ -51,8 +51,10 @@
|
|||
<div class="field_text oe_compact oe_compact_record">
|
||||
<a class="oe_compose_post" t-if="widget.options.compose_placeholder"><t t-raw="widget.options.compose_placeholder"/></a>
|
||||
<a class="oe_compose_post" t-if="!widget.options.compose_placeholder and !widget.options.view_mailbox">Send a message</a>
|
||||
<span class="oe_grey oe_sep_word">or</span>
|
||||
<a class="oe_compose_log">Log a note</a>
|
||||
<t t-if="widget.options.display_log_button">
|
||||
<span class="oe_grey oe_sep_word">or</span>
|
||||
<a class="oe_compose_log">Log an internal note</a>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
|
@ -155,7 +157,7 @@
|
|||
</t>
|
||||
</div>
|
||||
<div t-if="widget.is_log">
|
||||
<span>Attach a note that will not be sent to the followers</span>
|
||||
<span>Add an internal note that will not be sent to the followers</span>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
|
@ -293,9 +295,9 @@
|
|||
logged a note
|
||||
</t>
|
||||
<t t-if="(widget.type == 'comment' or widget.type == 'email') and (widget.subtype or widget.partner_ids.length > 0)">
|
||||
to
|
||||
<t t-if="widget.partner_ids.length == 0">
|
||||
nobody
|
||||
<!-- Remove nobody if user have no rights on partner that will display 'portal to nobody 5 minutes ago' that will confuse to end user, now it display 'portal 5 minutes ago' if no rights.-->
|
||||
<t t-if="widget.partner_ids.length > 0">
|
||||
to
|
||||
</t>
|
||||
</t>
|
||||
<t t-if="widget.type == 'notification' or ( (widget.type == 'email' or widget.type == 'comment') and (widget.subtype or widget.partner_ids.length > 0))"
|
||||
|
|
Loading…
Reference in New Issue