Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
3129 Lượt xem

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,
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 23
3421
3
thg 2 23
5419
3
thg 11 24
2936
1
thg 2 24
1775
2
thg 5 23
3255