Skip to Content

Welcome!

Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

Sign up

You need to be registered to interact with the community.
This question has been flagged
1 Reply
66 Views

Hey team !


So here's the context, I'm using the 'helpdesk.ticket' thingy and a NodeJS library called 'odoo-await' that let me send XMLRPC request from a NodeJS app.


What I want to do is:

1. Create a new 'helpdesk.ticket'

2. Add a comment to the newly created ticket, I'm using the 'mail.message' model

3. I want that comment to have an attachment 'ir.attachment'


Right now I successfully created the ticket, the comment to that ticket and the orphan attachment.


My issue is that I'm not able to add the attachment to the 'mail.message' comment.


I first create the attachment so that I can use it's ids ('file_id') to put it in the 'attachment_ids' fields, and then create the comment with the code below :


await odoo.create('mail.message', {
model: 'helpdesk.ticket',
attachment_ids: [(6, 0, file_id)],
message_type: 'comment',
res_id: ticket_id
})

This code create the comment, and I tried multiple configuration for the 'attachment_ids' fields :

attachment_ids: [file_id]

attachment_ids: [(file_id)]

attachment_ids: [(0, file_id)]

attachment_ids: [[0, file_id]]

attachment_ids: [(6, 0, file_id)]

attachment_ids: [[6, 0, file_id]]

attachment_ids: [('6', '0', file_id)]

attachment_ids: [['6', '0', file_id]]


And also all these configurations with file_id as a String instead of an Int


No matter what I do in the end, when I check the new comment, the 'attachment_ids' field is always empty.


Any hints on what I'm doing wrong ?


I'm kinda lost on what the (6, 0, id) m2m represent, but I saw it in a bunch of other answer to similar issue.

I also tried reading the source code for mail.message, but yeah, python isn't really my thing...


Thanks everyone reading this.

Have a good day

Avatar
Discard

I will close this issue since I found another way to do what I needed.

When creating the 'ir.attachment' I set the 'res_id' to the previously created ticket ID, so that the attachment can be seen in the the attachment tab of the 'helpdesk.ticket'.

Avatar
Discard

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!