I implemented a model that inherits from 'mail.thread' and in the form view I want to show only the "message_ids" that are of the type 'comment' and also that this session is visible for a given state of that model. This is part of the code I am talking about.
this is my .py
class ModelModel(models.Model):
_name = 'myModel.myModel'
_inherit = ['mail.thread']
STATE_SELECTION = [
('draft', 'Draft'),
('open', 'Open'),
('closed', 'Closed'),]
name = fields.Char(string='Name')
state = fields.Selection(string='Status', selection=STATE_SELECTION, default='draft')
....
this is my .xml
<record model="ir.ui.view" id="model_model_view_form">
<field name="name">myModel.myModel.view.form</field>
<field name="model">myModel.myModel</field>
<field name="arch" type="xml">
<form>
<header>
<field name="state" widget="statusbar" statusbar_visible="draft,open,closed"/>
</header>
<sheet>
<div class="oe_title">
<div class="oe_edit_only" states="draft">
<label for="name"/>
</div>
<h1><field name="name" class="oe_inline"/></h1>
</div>
</sheet>
<div class="oe_chatter">
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
to apply domain try with this:
<div class="oe_chatter">
<field name="message_ids" widget="mail_thread" domain="[('message_type', '=', 'comment')]"/>
</div>
to hide/show this part try with this:
<div class="oe_chatter"
attrs="{'invisible': [('state', 'in', ['draft', 'closed'])]}"
>
<field name="message_ids" widget="mail_thread"/>
</div>
but none of this resulted.
Thanks
I found part of the solution to the two problems. it turns out that:
<div attrs="{'invisible': [('state', '!=', 'open')]}">
<div class="oe_chatter">
<field name="message_ids" widget="mail_thread"/>
</div>
</div>
this turned out for me.
These tips help you to get the basic idea about customization in odoo
https://learnopenerp.tumblr.com/