From d3a7b0e1b1dffd73b9ff31f1ec9fa4f6bbf478d2 Mon Sep 17 00:00:00 2001
From: Nicolas Martinelli <nim@odoo.com>
Date: Wed, 27 Nov 2019 07:00:07 +0000
Subject: [PATCH] [FIX] stock_barcode: put in pack in receipt

- Activate product packing
- Create a PO for a stockable product, validate
- In the barcode interface, go to the created picking
- Set the product quantity
- Click on 'Put in Pack'

An error is raised: 'All the products currently reserved in the picking
are already in a pack...'

In the regular interface, the procedure is to create the move lines
manually, therefore setting a quantity done. However, this is not
possible in the barcode, and `move_line_nosuggest_ids` is always empty.

We introduce a special use case to bypass this in the case of the
barcode view.

opw-2127637
---
 addons/stock/models/stock_picking.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py
index 4f7f43f62ae6..e63557a2dbc0 100644
--- a/addons/stock/models/stock_picking.py
+++ b/addons/stock/models/stock_picking.py
@@ -1181,7 +1181,10 @@ class Picking(models.Model):
         self.ensure_one()
         if self.state not in ('done', 'cancel'):
             picking_move_lines = self.move_line_ids
-            if not self.picking_type_id.show_reserved:
+            if (
+                not self.picking_type_id.show_reserved
+                and not self.env.context.get('barcode_view')
+            ):
                 picking_move_lines = self.move_line_nosuggest_ids
 
             move_line_ids = picking_move_lines.filtered(lambda ml:
-- 
GitLab