Skip to Content
Menu
This question has been flagged
3 Replies
2035 Views

Hello,

I'm trying to add a new LogNote to my Order Delivery via JSON-RPC but I can't seem to get it. Can anyone show me how to do it?

The following is the raw request made by the platform which I'm using as reference:

{"id":12,
"jsonrpc":"2.0",
"method":"call",
"params":{
	​"context":{
		​"mail_post_autofollow":false,
		​"temporary_id":523.01},
		​"post_data":{
			​"body":"Test",
			​"attachment_ids":[],
			​"attachment_tokens":[],
			​"message_type":"comment",
			​"partner_ids":[],
			​"subtype_xmlid":"mail.mt_note",
			​"partner_emails":[]},
	​"thread_id":32,
	​"thread_model":"stock.picking"}
}


Best regards,
Avatar
Discard
Best Answer

Hi,
Refer the code to add lognotes in stock.picking

notes = '%s' % '' + str(request.jsonrequest['inventoryMode']) + " - " + str(
request.jsonrequest['inventoryState']) + '' + '
'
+ ' Market: ' + str(
request.jsonrequest['location']) + '
'
+ ' Device date time: ' + str(
request.jsonrequest['deviceDateTime']) + '
'
+ str(request.jsonrequest['description'])

log_note = request.env['mail.message'].sudo().create({
'res_id': market.id,
'body': notes,
'model': 'stock.picking',
'email_from': request.jsonrequest['email'],
'attachment_ids': data,
})


Hope it helps you

Avatar
Discard
Best Answer

you can use the message_post method of the stock.picking model. Here's an example of how you can construct the JSON-RPC request:
{

"id": 12,

"jsonrpc": "2.0",

"method": "call",

"params": {

"model": "stock.picking",

"method": "message_post",

"args": [

32, // thread_id

"Test", // body (your log note content)

false, // subtype_xmlid (mail.mt_note) - You can set to false to use the default value

false, // parent_id (you can set it to false)

false, // attachment_ids (you can set it to false or an empty list [])

false, // partner_ids (you can set it to false or an empty list [])

false, // attachment_tokens (you can set it to false or an empty list [])

false // partner_emails (you can set it to false or an empty list [])

],

"kwargs": {

"context": {

"mail_post_autofollow": false,

"temporary_id": "523.01"

}

}

}

}


Explanation of parameters:

  • model: The model name ("stock.picking" in this case).
  • method: The method name ("message_post" to add a new LogNote).
  • args: A list of arguments for the method. Here, you pass the thread_id of the Order Delivery, the log note content ("Test" in this case), and other optional parameters (you can set them to false or an empty list []).
  • kwargs: Additional keyword arguments. Here, you pass the context, which can include some context variables like mail_post_autofollow and temporary_id.

You can make this JSON-RPC request to the Odoo server using your preferred HTTP client library, such as requests in Python or axios in JavaScript. Make sure to replace 32 in the args with the actual thread_id of your Order Delivery. After sending the request, a new LogNote with the specified content will be added to the Order Delivery.

Avatar
Discard
Best Answer

Try to call message_post of the stock.picking​ model with the values of the post_data that shows on the example request you have

Avatar
Discard
Related Posts Replies Views Activity
1
Jan 23
2689
3
Feb 23
4527
3
Nov 24
2172
1
Feb 24
1164
2
May 23
2378