[IMP]: reduce rpc call , add options 'display_log_button' on field,

[REM]: unwanted record rule

bzr revid: aja@tinyerp.com-20130923133201-zclwecr2n596e989
This commit is contained in:
ajay javiya (OpenERP) 2013-09-23 19:02:01 +05:30
parent de52e90cfa
commit cbe9d337a5
3 changed files with 22 additions and 24 deletions

View File

@ -1660,3 +1660,19 @@ class mail_thread(osv.AbstractModel):
}
threads.append(data)
return sorted(threads, key=lambda x: (x['popularity'], x['id']), reverse=True)[:3]
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
if context is None: context = {}
flag = 0
from lxml import etree
group = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user')
if group:
users = self.pool.get('res.groups').read(cr, uid, group[1], ['users'])['users']
flag = uid in users and 1 or 0
res = super(mail_thread, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
doc = etree.XML(res['arch'])
if view_type == 'form':
for node in doc.xpath("//field[@name='message_ids']"):
node.set('display_log_button',str(flag))
res['arch'] = etree.tostring(doc)
return res

View File

@ -38,23 +38,6 @@
<field name="perm_unlink" eval="False"/>
</record>
<record id="mail_message_internal_note_employee" model="ir.rule">
<field name="name">mail.message</field>
<field name="model_id" ref="model_mail_message"/>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
<field name="domain_force">[('type', 'in', ['comment','email','notification'])]</field>
</record>
<record id="mail_message_internal_note_all_user" model="ir.rule">
<field name="name">mail.message</field>
<field name="model_id" ref="model_mail_message"/>
<field name="domain_force">[('type', 'in', ['email','notification'])]</field>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="True"/>
</record>
<!--
This rule can not be uncommented, because we have a more wide method in mail.message. When we implement a many2one_variable field, we will be able to uncomment this.
<record id="mail_message_read_partner_or_author" model="ir.rule">

View File

@ -1794,14 +1794,15 @@ openerp.mail = function (session) {
this._super.apply(this, arguments);
this.ParentViewManager = parent;
this.node = _.clone(node);
this.node.params = _.extend({
console.log(self.node);
this.node.params = _.extend({
'display_indented_thread': -1,
'show_reply_button': false,
'show_read_unread_button': true,
'read_action': 'unread',
'show_record_name': false,
'show_compact_message': 1,
'display_log_button' : false,
'display_log_button' : 1,
}, this.node.params);
if (this.node.attrs.placeholder) {
this.node.params.compose_placeholder = this.node.attrs.placeholder;
@ -1809,16 +1810,14 @@ openerp.mail = function (session) {
if (this.node.attrs.readonly) {
this.node.params.readonly = this.node.attrs.readonly;
}
if (this.node.attrs.display_log_button){
this.node.params.display_log_button = parseInt(this.node.attrs.display_log_button);
}
this.domain = this.node.params && this.node.params.domain || [];
if (!this.ParentViewManager.is_action_enabled('edit')) {
this.node.params.show_link = false;
}
this.dataset = new session.web.DataSet(this,"ir.actions.client");
this.dataset.call('check_message_security', [this.session.uid]).then(function(result){
self.node.params.display_log_button = result;
});
},
start: function () {