1.5 KiB
1.5 KiB
MO Lock Consumed
Overview
This module prevents the Consumed Quantity of Manufacturing Order components from being automatically reset or scaled by Odoo when:
- The Quantity to Produce on the MO header is changed (System Scaling).
- 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_consumptionFlag: This flag is set toTruewhenever a move has a positive quantity set._should_bypass_set_qty_producing: Overridden to returnTrueif:manual_consumptionis set.- OR the record is "Virtual" (NewId) and has
quantity > 0. This bypasses Odoo's default scaling logic.
writeGuard: Blocks writingquantity=0to locked moves, preventing resets.createCheck: Locks new moves immediately if they are created with a specificquantity(Consumed), while ignoringproduct_uom_qty(Demand) to allow initial auto-fill.