Go to file
2026-02-13 14:51:20 +07:00
models feat: Remove functionality to hide produce buttons on negative stock. 2026-02-13 14:51:20 +07:00
__init__.py first commit 2026-02-06 18:05:38 +07:00
__manifest__.py feat: Remove functionality to hide produce buttons on negative stock. 2026-02-13 14:51:20 +07:00
.gitignore first commit 2026-02-06 18:05:38 +07:00
README.md feat: Enhance consumed quantity locking for MO components, adding virtual record support and immediate locking on creation. 2026-02-11 11:20:44 +07:00

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.