Skip to Content
Menu
This question has been flagged
2 Replies
2144 Views

Executing the follow RPC, results in a json object return instead of "true" as expected.

When I hit the button in the GUI, a popup comes up and forces me to confirm the validation.

The json return from the RPC, it is apparent, is the popup definition!

{   "jsonrpc""2.0",     "method":"call",    "id":921359310,    

"params": {        "service":"object",        "method":"execute_kw",        

"args": [ "mydb""77""mypw""stock.picking""button_validate", [[27]]]  }}


Two questions:

1. Is it possible to execute the stock.picking "button_validate" and skip the popup?  (Is there another call that I am overlooking?)

2. If I want to do a stock_immediate_transfer  "process" instead, what are the id arguments?

I tried it with move ids, but that did not work.

Avatar
Discard
Author

OK, having tried the following:
{ "jsonrpc": "2.0",
"method":"call",
"id":921359310,
"params": {
"service":"object",
"method":"execute_kw",
"args": [ "mydb", "77", "mypw", "stock.picking", "button_validate", [[29]],
{ "context": {"skip_backorder":true} } ]
}
}
But, I still get back some popup json:
{
"jsonrpc": "2.0",
"id": 921359310,
"result": {
"name": "Immediate Transfer?",
"type": "ir.actions.act_window",
"view_mode": "form",
"res_model": "stock.immediate.transfer",
"views": [
[
1058,
"form"
]
],
"view_id": 1058,
"target": "new",
"context": {
"skip_backorder": true,
"button_validate_picking_ids": [
29
],
"default_show_transfers": false,
"default_pick_ids": [
[
4,
29
]
]
}
}
}
So, at this point I am feeling a little stupid, or at least that I didn't understand the "context" shorthand. This seems to indicate it wants to validate picking_id 29, but just won't do it. Is that correct?

Author

We're running V15 in Odoo.sh, by the way.

Author

The json I posted contains "name": "Immediate Transfer?", which looks like it's generated in code that is protected by 'skip_immediate' not 'skip_backorder'
We'll be trying that next.

Author

When skip_immediate is also added to the context, the call returns:
{
"jsonrpc": "2.0",
"id": 921359310,
"result": true
}

But the stock.picking record does not move inventory or change state.

Author Best Answer

What finally seems to work for me is to execute one call with:

       "args": [ "mydb""77""mypw""stock.picking""action_set_quantities_to_reservation", [[30]] ]

which is the equivalent of the "Set Quantities" button, followed by this:

        "args": [ "mydb""77""mypw""stock.picking""button_validate", [[30]], { "context": {"skip_backorder"true"skip_immediate"true}} ]

which is the equivalent of the "Validate" button.   It's not clear if the context is still required in the second call, but it doesn't seem to hurt.

Thanks to Ray for his comments and especially the link to the code.  I would be especially interested to understand why the "button_validate" with context failed to do the job.

 

Avatar
Discard
Best Answer

At v14 we added a context key called skip_backorder.

See it in the code at https://github.com/odoo/odoo/blob/14.0/addons/stock/models/stock_picking.py#L982

Send this key in context when you make your call.

Avatar
Discard
Author

Thanks. I'll be trying this on Monday. As a long-time developer, but newbie on Odoo, I am still wrestling with the oddness of the codebase. That stock_picking.py, for example, is nothing like the version in the community edition that I have downloaded and the GitHub code for our Odoo.sh instances are currently opaque to us. A very frustrating experience.

We have versions. I linked you to Odoo 14 which was released in 2020. You can post your version in future posts as answers can be version dependent.

Related Posts Replies Views Activity
2
Feb 23
2125
1
Nov 24
16349
2
Nov 24
1350
1
Sep 23
857
2
Dec 22
1681