Skip to Content
Menu
This question has been flagged

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
Author Best Answer

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
Best Answer

I have PDF files of prior employee payslips on a CD. I'd like to import these into OpenERP as attachments for each employee. In addition, I'd like to submit more files each month. To do this, I intend to develop a particular module/addon or a Python program that will access OpenERp through XML-RPC.

Avatar
Discard

Does anyone have a solution for this https://dino-game.org problem?

Related Posts Replies Views Activity
2
Sep 22
3485
1
Jan 23
1506
2
May 18
5702
0
Jul 17
1912
1
Aug 20
2951