From 64237aa3abc7b85fa6c513a4cd31aae1fc004e39 Mon Sep 17 00:00:00 2001 From: amoyaux Date: Mon, 9 Oct 2017 18:08:40 +0200 Subject: [PATCH] [FIX] stock: package transfer shows related pickings Use case to reproduce: - Create a picking with a package - Go to the source or destination package - Click on package transfers -> It displays all the pickings This happens because the package transfer button calls the all picking tree view that display them. This commit use an action instead that will add a domain on it in order to only display the pickings that used the selected package. opw-774013 --- addons/stock/models/stock_quant.py | 11 +++++++++++ addons/stock/views/stock_quant_views.xml | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 1c11ad0c99f..a67706f712b 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -694,6 +694,17 @@ class QuantPackage(models.Model): raise UserError(_('Everything inside a package should be in the same location')) return True + @api.multi + def action_view_related_picking(self): + """ Returns an action that display the picking related to this + package (source or destination). + """ + self.ensure_one() + pickings = self.env['stock.picking'].search(['|', ('pack_operation_ids.package_id', '=', self.id), ('pack_operation_ids.result_package_id', '=', self.id)]) + action = self.env.ref('stock.action_picking_tree_all').read()[0] + action['domain'] = [('id', 'in', pickings.ids)] + return action + @api.multi def unpack(self): for package in self: diff --git a/addons/stock/views/stock_quant_views.xml b/addons/stock/views/stock_quant_views.xml index c25f6a853d5..0af74419b40 100644 --- a/addons/stock/views/stock_quant_views.xml +++ b/addons/stock/views/stock_quant_views.xml @@ -176,8 +176,8 @@
-