2

I am an odoo beginner and I am currently developing an inventory mobile app for accessing odoo remotely with XMLRPC.

I am able to set "qty_done" field for each stock.move.line in delivery order (stock.picking) and when order is complete I am able to call button_validate method and complete the order.

My goal is to create backorder from unfinished delivery order when calling button_validate method with XMLRPC.

My problem is that in odoo web client when validating delivery order wizard is opened but I would like to create backorder with XMLRPC.

enter image description here

Calling button_validate method from python with XMLRPC on unfinished delivery order return this view and i dont know how should i go about it.

{'name': 'Create Backorder?', 'type': 'ir.actions.act_window', 'view_mode': 'form', 'res_model': 'stock.backorder.confirmation', 'views': [[1530, 'form']], 'view_id': 1530, 'target': 'new', 'context': {'button_validate_picking_ids': [27], 'default_show_transfers': False, 'default_pick_ids': [[4, 27]]}}

Any help will be greatly appreciated

Twage Mwakajumba
  • 68
  • 1
  • 1
  • 10
xixo222
  • 157
  • 2
  • 9
  • Try to create a `stock.backorder.confirmation` record with the same values as `pick_ids(4, 27)` then call `process` function. – Kenly Jul 26 '21 at 18:51
  • Thank you for your answer. This approach would require me to create a record in stock.backorder.confirmation.line as well right? I saw that the method default_get does that, but i could not find anywhere in the code call to this function. Would it be possible to use the default_get function for the line creation? – xixo222 Jul 27 '21 at 15:06
  • Use the default values in the context of the return action: `'context': {'button_validate_picking_ids': [27], 'default_show_transfers': False, 'default_pick_ids': [[4, 27]]}` – Kenly Jul 27 '21 at 16:35
  • @Kenly Thank you SO MUCH. I finaly got it working thanks to you. I was actually relatively close in the beggining (i was using context, but only `default_pick_ids`), but adding `button_validate_picking_ids` as well was the key. – xixo222 Jul 28 '21 at 07:48

2 Answers2

1

Thinking about it, why you don't create a method at Odoo side, and call it from xmlrpc with the minimal necesary parameters, and inside this new method write all your logicals. Give to Odoo the responsability, and keep as simple as posible your external app. If you need anything else, let me know.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Thank you so much for your answer. Could you be so kind and provide an example or some more details? I am a little confused from the context that is used and `default_get` method in `stock.backorder.confirmation` model – xixo222 Jul 27 '21 at 14:21
0

You said "but adding button_validate_picking_ids as well was the key." Could you tell me how you did hat ?

I'm also facing this problem, I'm migrating from 13 to 14 and my external xml-rpc script to validate delivery orders.... crash :-) In fact the method stock_backorder.confirmation.process() is not usable anymore as the stock_picking.button_validate() don't return the ID anymore....

Thanks

Hedge
  • 1
  • 1
  • Welcome to stack overflow! You would be better off asking this as a new question, or possibly as a follow-up comment to this question. Answers should only be for (attempting to) answer the original question. – Sam Aug 21 '21 at 10:31