From 319ae318601dcfb59bf02b2bd8d29f78f0ff46ba Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Wed, 31 Jul 2019 12:35:26 +0000 Subject: [PATCH] [FIX] stock: same origin documents Create two moves with a product MTO and the same SO. Confirm them. It will generate a new picking without origin. However the purpose of removing origin on picking is to avoid an endless enumaration of all documents but if they only have one origin it should be display. In this case, the origin was ignored because moves.mapped('origins') result in a list of ['doc_origin','doc_origin'] and have a length of 2 because .mapped do not return a distinct set on fields different than Many2one, one2Many and M2M. --- addons/stock/models/stock_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 35a4d97c8a8..f3a9752446f 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -872,8 +872,8 @@ class StockMove(models.Model): """ return create values for new picking that will be linked with group of moves in self. """ - origins = self.filtered(lambda m: m.origin).mapped('origin') - origin = len(origins) == 1 and origins[0] or False + origins = set(self.filtered(lambda m: m.origin).mapped('origin')) + origin = len(origins) == 1 and origins.pop() or False partners = self.mapped('partner_id') partner = len(partners) == 1 and partners.id or False return {