Skip to Content
Menu
This question has been flagged
1 Reply
3604 Views

Hi everyone,


Aiming to create a space for a private image gallery, we'd like to show the Attachment button in the chatter ONLY to a custom group:




Any way to do this in Odoo Online?


Thanks!

Avatar
Discard
Best Answer

I don't know if this is the proper way but it works for Odoo 12.


Now you can add the attribute hide_to with the name of the group in the oe_chatter div (You also need to replace * with div tag in `appendTo($('*'))` )



// in your xml add this attribute to the oe_chatter div: // hide_to="your_module.your_group"

odoo.define('custom_widgets.chatter', function (require) {   

"use strict";

const Chatter = require('mail.Chatter');   

const FormRenderer = require('web.FormRenderer');   

const Session = require('web.session');

FormRenderer.include({       

    _renderNode: function (node) {

        if (node.tag === 'div' && node.attrs.class === 'oe_chatter') {

        const disable_attachment_box = this._disableAttachmentBox(node.attrs)

        if (!this.chatter) {

            this.chatter = new Chatter(this, this.state, this.mailFields, {                       

            isEditable: this.activeActions.edit,                       

            viewType: 'form',                       

            disable_attachment_box: disable_attachment_box,

        });                   

        this.chatter.appendTo($('*'));

        this._handleAttributes(this.chatter.$el, node);

        } else {  this.chatter.update(this.state); }               

        return this.chatter.$el;           

    }  else {               

        return this._super.apply(this, arguments);           

    }       

},         

_checkGroup: function (group) {           

return Session.user_has_group(group).then((res) => { return res });       

},       

_disableAttachmentBox: function (attrs) {           

    const disable = 'disable_attachment_box' in attrs;

    if ("hide_to" in attrs && attrs.hide_to)                

        return disable || this._checkGroup(attrs.hide_to); 

    else return disable      

}   

});

});





Avatar
Discard
Related Posts Replies Views Activity
0
Jun 19
2320
1
May 16
5143
1
Nov 23
788
1
Mar 23
1027
2
Oct 19
4432