This question has been flagged
1 Reply
2964 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