Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6446 มุมมอง

Hello guys, 

I have a question about the Chatter: (mail.thread)

I have a Wizard that allows me to add an Attachment. When I click Send, the Attachment should be in the Chat with a body (please see attached file)  so that the followers can see it.


here's my code

piece= fields.Many2many('ir.attachment', string="Pièce", required=True)
@api.multi
def Envoi_Justif(self):
    subject = u" Pièce Justificative"
    body = u" please see attached file here "
    self.message_post(body, attachments_ids=[ self.piece_justif],  subject=subject.encode('utf-8'),  type="notification")

XML:

Field & Button

<field name="piece" widget="many2many_binary"/>
<button
    name="Envoi_Justif"
    type="object"
    string="Send"
    class="oe_highlight"
/>

 when i click Send, it gives me this error : 

File "/opt/odoo/addons/mail/mail_thread.py", line 1595, in message_post
    thread_id = thread_id[0]
IndexError: list index out of range

any help would be appreciated

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Resolved

I just needed to add 'mail.compose.message' to _inherit and change attachments_ids  to attachment_ids

and finally tell odoo where i want to put the attachment ( in my case, i defined a field Many2one to my target)


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Don't send a message on creation แก้ไขแล้ว
3
ก.ค. 21
10643
1
ต.ค. 21
4844
0
มิ.ย. 16
3881
1
ธ.ค. 23
4830
1
พ.ย. 23
1847