feat: Enforce manual consumption and picked flags on stock move quantity write and update consumption bypass conditions.
This commit is contained in:
parent
7b4130fc6c
commit
1ff922db7b
@ -7,6 +7,7 @@ This Odoo module customizes the behavior of Manufacturing Orders (MO) regarding
|
||||
1. **Lock Consumed Quantity**:
|
||||
- Prevents the automatic update of a component's "Consumed" quantity when the MO's "Quantity to Produce" is changed, **IF**:
|
||||
- The component already has a manually entered "Consumed" quantity (greater than 0).
|
||||
- The component is marked as **Picked** (manual consumption) or has **Manual Consumption** flag set.
|
||||
|
||||
- If a component has 0 consumed quantity and is not picked, it will continue to scale automatically based on the BOM ratio (standard behavior).
|
||||
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
from . import stock_move
|
||||
from . import mrp_production
|
||||
|
||||
|
||||
@ -9,6 +9,13 @@ class StockMove(models.Model):
|
||||
- The move already has a quantity set (partial consumption).
|
||||
- The move is already picked.
|
||||
"""
|
||||
if self.quantity > 0:
|
||||
if self.sudo().quantity > 0 or self.sudo().picked or self.sudo().manual_consumption:
|
||||
return True
|
||||
return super()._should_bypass_set_qty_producing()
|
||||
|
||||
def write(self, vals):
|
||||
# Enforce manual usage flags if quantity is being set
|
||||
if 'quantity' in vals and vals['quantity'] > 0:
|
||||
vals['manual_consumption'] = True
|
||||
vals['picked'] = True
|
||||
return super().write(vals)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user