[IMP] mrp: cascade qty update from MO to next pickings
If a warehouse is set to a route like default 3-steps, updating the MO's quantity to produce won't update the outgoing picking from post-production to stock. Since the quantity is now changed in the following pickings, no need to put a warning in those pickings for the quantity change as their moves quantity were automatically updated. Task-2797359 closes odoo/odoo#86572 Signed-off-by: Arnold Moyaux <arm@odoo.com>
This commit is contained in:
@@ -33,14 +33,26 @@ class ChangeProductionQty(models.TransientModel):
|
||||
modification during production would not be taken into consideration.
|
||||
"""
|
||||
modification = {}
|
||||
push_moves = self.env['stock.move']
|
||||
for move in production.move_finished_ids:
|
||||
if move.state in ('done', 'cancel'):
|
||||
continue
|
||||
qty = (new_qty - old_qty) * move.unit_factor
|
||||
modification[move] = (move.product_uom_qty + qty, move.product_uom_qty)
|
||||
move.write({'product_uom_qty': move.product_uom_qty + qty})
|
||||
if self._need_quantity_propagation(move, qty):
|
||||
push_moves |= move.copy({'product_uom_qty': qty})
|
||||
else:
|
||||
move.write({'product_uom_qty': move.product_uom_qty + qty})
|
||||
|
||||
if push_moves:
|
||||
push_moves._action_confirm()._action_assign()
|
||||
|
||||
return modification
|
||||
|
||||
@api.model
|
||||
def _need_quantity_propagation(self, move, qty):
|
||||
return move.move_dest_ids and not float_is_zero(qty, precision_rounding=move.product_uom.rounding)
|
||||
|
||||
def change_prod_qty(self):
|
||||
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
|
||||
for wizard in self:
|
||||
@@ -71,9 +83,7 @@ class ChangeProductionQty(models.TransientModel):
|
||||
else:
|
||||
documents[key] = [value]
|
||||
production._log_manufacture_exception(documents)
|
||||
finished_moves_modification = self._update_finished_moves(production, new_production_qty - qty_produced, old_production_qty - qty_produced)
|
||||
if finished_moves_modification:
|
||||
production._log_downside_manufactured_quantity(finished_moves_modification)
|
||||
self._update_finished_moves(production, new_production_qty - qty_produced, old_production_qty - qty_produced)
|
||||
production.write({'product_qty': new_production_qty})
|
||||
|
||||
for wo in production.workorder_ids:
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
|
||||
from . import stock_picking_return
|
||||
from . import mrp_consumption_warning
|
||||
from . import change_production_qty
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class ChangeProductionQty(models.TransientModel):
|
||||
_inherit = 'change.production.qty'
|
||||
|
||||
@api.model
|
||||
def _need_quantity_propagation(self, move, qty):
|
||||
res = super()._need_quantity_propagation(move, qty)
|
||||
return res and not any(m.is_subcontract for m in move.move_dest_ids)
|
||||
Reference in New Issue
Block a user