I have written following code to add chatter feature for each student record. There are 3 records in the student table but it showing only one chatter section and all three names it showing output like follows:
John Doe
<Here chatter section displayed only once>
Jane smith
<chatter section displayed excepted to display but not displayed >
Alice Bob
<chatter section displayed excepted to display not displayed><t t-foreach="students" t-as="student">
<t t-if="student">
<div class="chat">
<t t-esc="student.student_name"/>
<t t-call="portal.message_thread">
<t t-set="object" t-value="student"/>
</t>
</div>
</t>
</t>
</div>
Please tell me the solution so it show the chatter functionality for three times as the names are displayed and also why it is showing the chatter section for one time only.
Bu soru işaretlendi
1
Cevapla
2728
Görünümler
Hi
The problem is related to how the portal message thread works in Odoo. When you use t-call="portal.message_thread" multiple times in the same view, it only renders once because of how Odoo's chatter component is designed.
You need to ensure each chatter has a unique ID. The message thread component needs to be able to distinguish between different record threads.
Modify your code to include a unique identifier for each chatter section:
<t t-foreach="students" t-as="student">
<t t-if="student">
<div class="chat">
<t t-esc="student.student_name"/>
<div t-attf-id="discussion_thread_#{student.id}" class="mt-4">
<t t-call="portal.message_thread">
<t t-set="object" t-value="student"/>
</t>
</div>
</div>
</t>
</t>
The key improvement in this version compared to your original code is the addition of the unique ID attribute (t-attf-id="discussion_thread_#{student.id}"). This creates a distinct container for each chatter with a unique identifier based on the student's ID, which helps Odoo properly initialize and render multiple chatter components on the same page.
Regards
Jishna
Tartışma hoşunuza mı gidiyor? Sadece okumakla kalmayın, katılın!
Özel özelliklerden yararlanmak ve harika topluluğumuzla etkileşime geçmek için bugün bir hesap oluşturun!
Üye Ol| İlgili Gönderiler | Cevaplar | Görünümler | Aktivite | |
|---|---|---|---|---|
|
|
2
Nis 25
|
3073 | ||
|
|
0
Tem 23
|
4200 | ||
|
|
0
Haz 23
|
4600 | ||
|
|
0
Kas 21
|
2332 | ||
|
|
0
Kas 16
|
5677 |