Go to file
2026-04-03 21:53:19 +07:00
models refactor: enhance location restriction logic with exhaustive context lookups and diagnostic logging 2026-04-03 21:53:19 +07:00
static/src/js refactor: enhance location restriction logic with exhaustive context lookups and diagnostic logging 2026-04-03 21:53:19 +07:00
views feat: Restrict lot selection dropdown to lots available in the source location for internal/transit pickings by adding a stock.lot search override and passing context variables from stock.move.line views. 2026-03-05 13:56:06 +07:00
__init__.py first commmit 2026-02-13 14:37:52 +07:00
__manifest__.py first commmit 2026-02-13 14:37:52 +07:00
.gitignore first commmit 2026-02-13 14:37:52 +07:00
README.md refactor: restrict location filtering to UI-only searches and remove backend reservation overrides to prevent validation errors. 2026-04-03 17:27:31 +07:00

Stock Restrict Source Location

This module implements targeted location filtering for Stock Moves and Manufacturing Orders, ensuring users can only pick components and stock from authorized source locations defined in the Operation Type.

Features

  • Surgical UI Filtering: Restricts the "Pick From" (Quant) and "Lot/Serial Number" (Lot) selection in both standard Transfers and MO "Detailed Operations" dialogs.
  • Backend Sync Safety: Specifically designed to bypass restrictions for background Odoo operations (reservation, unreservation, record-linking) to prevent "Missing Product" validation errors.
  • Context-Aware MO Support: Handles the complex Manufacturing Order "Components" view by injecting the correct picking type and source location into the search context.
  • Frontend Patch: Includes a JavaScript patch to ensure location context is correctly passed from the UI to the backend search methods.

Dependencies

  • stock
  • mrp
  • stock_picking_type_m2m (Used to configure the list of allowed locations on the Operation Type)

Usage

  1. Configure: On a Picking Type (Operation Type), set the Allowed Source Locations (M2M field).
  2. Operation: Create an MO or Transfer using that Picking Type.
  3. Lot Selection: When a user clicks to select a Lot or a Quant in the UI, the list will be filtered to only show availability from the allowed locations.
  4. Backend: Odoo's internal "Check Availability" and "Save" processes will still function normally, ensuring that reservations are linked correctly to existing stock.

Technical Implementation (V19)

  • Overrides StockQuant and StockLot _search methods with a UI-only bypass.
  • Only restricts queries that include UI indicators (like params, search_view_ref, or bin_size).
  • Bypasses restrictions for the system user (uid=False) and searches by direct ID to maintain ORM integrity.