From 3a37ebee1b0adb9018ebe61e7e4495c901eb98f8 Mon Sep 17 00:00:00 2001
From: Mmequignon <matthieu@fwzte.xyz>
Date: Wed, 13 Sep 2023 13:42:26 +0200
Subject: [PATCH] shopfloor_reception: Make select picking by product optional

---
 shopfloor_reception/data/shopfloor_scenario_data.xml | 3 ++-
 shopfloor_reception/services/reception.py            | 7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/shopfloor_reception/data/shopfloor_scenario_data.xml b/shopfloor_reception/data/shopfloor_scenario_data.xml
index d9ef7cf264..67b04aa823 100644
--- a/shopfloor_reception/data/shopfloor_scenario_data.xml
+++ b/shopfloor_reception/data/shopfloor_scenario_data.xml
@@ -9,7 +9,8 @@
       <field name="options_edit">
 {
       "auto_post_line": true,
-      "allow_return": true
+      "allow_return": true,
+      "scan_location_or_pack_first": true
 }
       </field>
   </record>
diff --git a/shopfloor_reception/services/reception.py b/shopfloor_reception/services/reception.py
index 1545981879..f61c31c01f 100644
--- a/shopfloor_reception/services/reception.py
+++ b/shopfloor_reception/services/reception.py
@@ -847,7 +847,12 @@ def start(self):
     def _scan_document__get_handlers_by_type(self):
         return {
             "picking": self._scan_document__by_picking,
-            "product": self._scan_document__by_product,
+            # only add the handler if scan_location_or_pack_first is disabled
+            "product": (
+                self._scan_document__by_product
+                if not self.work.menu.scan_location_or_pack_first
+                else None
+            ),
             "packaging": self._scan_document__by_packaging,
             "lot": self._scan_document__by_lot,
             "origin_move": self._scan_document__by_origin_move,