[FIX] stock_move: show source document

Install stock and sale. Create a sale with 2+ products, save and
confirm.
Look for the created picking.

There will be no source doument, because of
cb618e9a99
the behavior has changed when there are multiple source
document, possibly to avoid displaying the wrong source if they
differ.

Adding the possibility to display multiple source documents, eventually
truncating the list

opw-2117886

closes odoo/odoo#40098

X-original-commit: baad02d01b86a8d036524b789f046a54a878a729
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2019-11-12 08:39:05 +00:00
committed by fw-bot
parent 70c4e5611e
commit f52bcddccc
+10 -2
View File
@@ -907,8 +907,16 @@ class StockMove(models.Model):
""" return create values for new picking that will be linked with group
of moves in self.
"""
origins = set(self.filtered(lambda m: m.origin).mapped('origin'))
origin = len(origins) == 1 and origins.pop() or False
origins = self.filtered(lambda m: m.origin).mapped('origin')
origins = list(dict.fromkeys(origins)) # create a list of unique items
# Will display source document if any, when multiple different origins
# are found display a maximum of 5
if len(origins) == 0:
origin = False
else:
origin = ','.join(origins[:5])
if len(origins) > 5:
origin += "..."
partners = self.mapped('partner_id')
partner = len(partners) == 1 and partners.id or False
return {