[FIX] stock: do not update moves when writing quantities lower than UoM precision
Suppose product P has UoM U with rounding R, and the stock move has quantity Q. Edit the quantity done to be Q + e, with e << R. By the semantic of the UoM rounding, this should mean that no change has been done. However no such check was done, so a message was posted in chatter, of the form: The done move line has been corrected. P: Quantity : 1000.0 -> 1000.0000000000001 opw 2006831 closes odoo/odoo#34124 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
@@ -276,7 +276,10 @@ class StockMoveLine(models.Model):
|
||||
# When editing a done move line, the reserved availability of a potential chained move is impacted. Take care of running again `_action_assign` on the concerned moves.
|
||||
next_moves = self.env['stock.move']
|
||||
if updates or 'qty_done' in vals:
|
||||
for ml in self.filtered(lambda ml: ml.move_id.state == 'done' and ml.product_id.type == 'product'):
|
||||
mls = self.filtered(lambda ml: ml.move_id.state == 'done' and ml.product_id.type == 'product')
|
||||
if not updates: # we can skip those where qty_done is already good up to UoM rounding
|
||||
mls = mls.filtered(lambda ml: not float_is_zero(ml.qty_done - vals['qty_done'], precision_rounding=ml.product_uom_id.rounding))
|
||||
for ml in mls:
|
||||
# undo the original move line
|
||||
qty_done_orig = ml.move_id.product_uom._compute_quantity(ml.qty_done, ml.move_id.product_id.uom_id, rounding_method='HALF-UP')
|
||||
in_date = Quant._update_available_quantity(ml.product_id, ml.location_dest_id, -qty_done_orig, lot_id=ml.lot_id,
|
||||
|
||||
Reference in New Issue
Block a user