Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion shopfloor/data/shopfloor_scenario_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"unload_package_at_destination": true,
"multiple_move_single_pack": true,
"no_prefill_qty": true,
"scan_location_or_pack_first": true
"scan_location_or_pack_first": true,
"force_detailed_scan": true
}
</field>
</record>
Expand Down
25 changes: 25 additions & 0 deletions shopfloor/migrations/16.0.2.26.0/post-migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import json
import logging

from odoo import SUPERUSER_ID, api

_logger = logging.getLogger(__name__)


def migrate(cr, version):
if not version:
return
env = api.Environment(cr, SUPERUSER_ID, {})
cluster_picking_scenario = env.ref("shopfloor.scenario_cluster_picking")
_update_scenario_options(cluster_picking_scenario)


def _update_scenario_options(scenario):
options = scenario.options
options["force_detailed_scan"] = True
options_edit = json.dumps(options or {}, indent=4, sort_keys=True)
scenario.write({"options_edit": options_edit})
_logger.info(
"Option 'force_detailed_scan' added to scenario %s",
scenario.name,
)
21 changes: 21 additions & 0 deletions shopfloor/models/shopfloor_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ class ShopfloorMenu(models.Model):
compute="_compute_require_destination_package_is_possible"
)

force_detailed_scan = fields.Boolean(
help="Force the operator to explicitly scan the product, lot/serial number, "
"or package barcode to confirm a move line instead of relying on location "
"or system deductions.\n\n"
"Without this, Shopfloor may automatically validate unique products, lots, or packages "
"as soon as the location is scanned. In practice, the physical inventory at "
"the location might differ from what the system expects "
"leading to silent stock drift and broken traceability.",
)

force_detailed_scan_is_possible = fields.Boolean(
compute="_compute_force_detailed_scan_is_possible"
)

@api.onchange("unload_package_at_destination")
def _onchange_unload_package_at_destination(self):
# Uncheck pick_pack_same_time when unload_package_at_destination is set to True
Expand Down Expand Up @@ -553,6 +567,13 @@ def _compute_allow_quantity_exceeding_demand_is_possible(self):
menu.scenario_id.has_option("allow_quantity_exceeding_demand")
)

@api.depends("scenario_id")
def _compute_force_detailed_scan_is_possible(self):
for menu in self:
menu.force_detailed_scan_is_possible = menu.scenario_id.has_option(
"force_detailed_scan"
)

@api.constrains(
"move_line_search_sort_order", "move_line_search_sort_order_custom_code"
)
Expand Down
7 changes: 7 additions & 0 deletions shopfloor/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,13 @@ def _scan_line_by_location(self, picking, move_line, location):
),
sublocation=location,
)

# Prevent auto select of the move line in case detailed scan is ON
if self.work.menu.force_detailed_scan:
return self._response_for_start_line(
move_line,
sublocation=location,
)
quantity = self._get_prefill_qty(move_line)
return self._response_for_scan_destination(move_line, qty_done=quantity)

Expand Down
11 changes: 11 additions & 0 deletions shopfloor/tests/test_cluster_picking_scan_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,14 @@ def test_scan_line_error_not_found(self):
"NO_EXISTING_BARCODE",
{"message_type": "error", "body": "Barcode not found"},
)

def test_scan_line_prevent_location_scan(self):
self.menu.sudo().force_detailed_scan = True
self._simulate_batch_selected(self.batch, in_package=True)
line = self.batch.picking_ids.move_line_ids
self._scan_line_error(
line=line,
scanned=line.location_id.barcode,
message=None,
sublocation=line.location_id,
)
6 changes: 6 additions & 0 deletions shopfloor/views/shopfloor_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@
When selecting a move line, force the user to first scan a package or a location and not a product or a lot.
</div>
</group>
<group
attrs="{'invisible': [('force_detailed_scan_is_possible', '=', False)]}"
>
<field name="force_detailed_scan_is_possible" invisible="1" />
<field name="force_detailed_scan" />
</group>
<group
name="auto_post_line"
attrs="{'invisible': [('auto_post_line_is_possible', '=', False)]}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
export var batch_picking_line = Vue.component("batch-picking-line-detail", {
props: {
line: Object,
locationScanned: {
type: Boolean,
default: false,
},
articleScanned: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -38,7 +42,7 @@ export var batch_picking_line = Vue.component("batch-picking-line-detail", {
:key="'batch-picking-line-detail-1'"
:record="line"
:options="{main: true, key_title: 'location_src.name', title_action_field: {action_val_path: 'location_src.barcode'}}"
:card_color="utils.colors.color_for(articleScanned ? 'screen_step_done': 'screen_step_todo')"
:card_color="utils.colors.color_for(locationScanned || articleScanned ? 'screen_step_done': 'screen_step_todo')"
/>
<item-detail-card
:key="'batch-picking-line-detail-2'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const ClusterPicking = {
v-if="state_in(['start_line', 'scan_destination', 'change_pack_lot', 'stock_issue'])"
:line="state.data"
:article-scanned="state_is('scan_destination')"
:location-scanned="state.data.sublocation"
:show-qty-picker="state_is('scan_destination')"
/>
<batch-picking-line-actions
Expand Down
Loading