# MO Lock Consumed ## Overview This module prevents the **Consumed Quantity** of Manufacturing Order components from being automatically reset or scaled by Odoo when: 1. The **Quantity to Produce** on the MO header is changed (System Scaling). 2. The MO is saved or "Produce" is clicked (System Refresh/Web Save). ## Features - **Strict Locking**: Once a component's consumed quantity is set (manually or via "Produce"), it is **locked**. - **Auto-Fill Support**: Allows the initial auto-fill of quantities (from BOM demand) when creating an MO, but locks them immediately after. - **Virtual Record Support**: Protects quantities even on unsaved (New/Virtual) records, preventing unexpected reverts during creation. - **Manual Override**: Users can still manually change the quantity (if positive), which will update the locked value. Only *system resets* (to 0) or *scaling* are blocked. ## Technical Details - **`manual_consumption` Flag**: This flag is set to `True` whenever a move has a positive quantity set. - **`_should_bypass_set_qty_producing`**: Overridden to return `True` if: - `manual_consumption` is set. - OR the record is "Virtual" (NewId) and has `quantity > 0`. This bypasses Odoo's default scaling logic. - **`write` Guard**: Blocks writing `quantity=0` to locked moves, preventing resets. - **`create` Check**: Locks new moves immediately if they are created with a specific `quantity` (Consumed), while ignoring `product_uom_qty` (Demand) to allow initial auto-fill.