Skip to Content
Menu
This question has been flagged
5 Replies
5766 Views

Right, so this was probably asked a bunch of times (\like here) , but I'm trying to get the chatter in my custom module.

in my models.py, I have _inherit like below

_inherit = ['mail.thread', 'ir.needaction_mixin']

 At the bottom of my form inside views.xml, I have this

</sheet>
</form>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="message_ids" widget="mail_thread">
</div>

Finally inside __openerp__.py, I have this

'depends': ['base', 'mail'],

The chatter still does not appear, I have even tried putting it inside the sheet and even using sheet position="after" to no avail. That just creates a white box with nothing in it.


Any help would be greatly appreciated.

Avatar
Discard
Author

(Can't edit my question, just says 403 forbidden...)

EDIT:

If I open my custom module inside Chrome's inspector, I can see the oe_chatter div. In the same div however, I also see the class o_form_invisible.

In the web.assest_backend.0.css file, ".o_form_invisible" simply sets "display: none !important;"

If I remove the class from the div element (and also from the div containing o_followers), the chatter appears and functions correctly. Refreshing the page will make Odoo apply that class again to these elements.

How can I prevent odoo from applying the o_form_invisible class to the chatter elements?

Best Answer

Everything you have done is correct, except for view definition

Place the oe_chatter div inside form, but after the sheet, hence your code should like this

    </sheet>
    <div class="oe_chatter">
        <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
        <field name="message_ids" widget="mail_thread">
    </div>
</form>


Further if you just need the Chatter box, then ''mail.thread' alone is enough, 

However if you need notification on unread messages on the List/Tree view then use ''ir.needaction_mixin', along with the associated field 'message_unread' in the Tree View, something like below

<tree fonts="bold:message_unread==True" string="TREE VIEW">                    
    <field name="message_unread" invisible="1"/>


Hope this helps you.

Avatar
Discard
Author

Hello Deep,

I've tried as you suggested and my view now looks like yours and I get the same result. I should have mentioned this in my OP, but I was pressed for time and only had a few minutes to write it.

I have already tried having it inside the form element and outside. I've even put it inside the main sheet, but after the closing notebook tag.

However, I just used the inspector and saw that the o_chatter div also had a class of o_form_invisible.

If I remove that, the chatter appears (and if I remove o_form_invisible from o_followers, the follower buttons also appear) and I can log messages.

When the page is refreshed, it will again have that class. Would you know how to prevent odoo from applying the class?

Hmmmm, not sure what could have gone wrong in the first place... but good to see that you have found a fix.. :)

Author Best Answer

I found a solution, but it's incredibly ungraceful and may impact more than just this module.

Inside your view (or if you are already loading CSS files), do something similar to below

<form string="Test">
<style>
.openerp .o_form_invisible { display: block !important; }
</style>
// The rest of your form
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>

This is not optimal because it may override other things that should be marked invisible and it forces use of !important for every future override that needs to be done with this class.

Manually adding a different class to show the element will not work as CSS rules are evaluated on a "What was added last" basis, and o_form_invisible gets added after any manually added classes.

Avatar
Discard
Author

Yes this solution does not fully work. It will show other fields that must be in the form, but are designed to be hidden from the user.

Applying the hidden class will not work because of the previous override

Best Answer

Hi, try to put it after the sheet closing and before the form closing :

                    </sheet> 
    <div class="oe_chatter">
        <field name="message_follower_ids" widget="mail_followers"/>
        <field name="message_ids" widget="mail_thread"/>
    </div>
</form>
Avatar
Discard
Related Posts Replies Views Activity
0
Feb 18
3358
1
Apr 16
3563
3
Aug 17
2748
0
Nov 24
95
1
Aug 24
669