Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Odoo 9 oe_chatter in custom module

By
David Todd
on 10/25/16, 6:03 PM 135 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.

(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?

David Todd
on 10/26/16, 10:30 AM
1

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 10/26/16, 2:36 AM

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.

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?

David Todd
on 10/26/16, 10:19 AM

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

deep
on 10/27/16, 4:28 AM
0
David Todd
On 10/26/16, 10:54 AM

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.

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

David Todd
on 10/26/16, 11:02 AM
0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 10/26/16, 2:35 AM

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>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/25/16, 6:03 PM
Seen: 135 times
Last updated: 10/26/16, 10:54 AM