From 3ee5a6af73527cd15f9feb84fe7367fb9046614d Mon Sep 17 00:00:00 2001 From: Hetashree Chauhan Date: Fri, 29 Sep 2017 17:37:14 +0200 Subject: [PATCH] [FIX] sale_stock: sale order picking form view If there is only a single picking in the sales order, it will open formview, else it will open tree view for all pickings --- addons/sale_stock/models/sale_order.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 35f85525980..ec628a5b1b5 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -58,7 +58,13 @@ class SaleOrder(models.Model): view, if there is only one delivery order to show. ''' action = self.env.ref('stock.action_picking_tree_all').read()[0] - action['domain'] = [('id', 'in', self.picking_ids.ids)] + + pickings = self.mapped('picking_ids') + if len(pickings) > 1: + action['domain'] = [('id', 'in', pickings.ids)] + elif pickings: + action['views'] = [(self.env.ref('stock.view_picking_form').id, 'form')] + action['res_id'] = pickings.id return action @api.multi