[FIX] stock_account: check new qty_done before creating a SVL

closes odoo/odoo#114962

X-original-commit: d26dc33dea43c51cb5a4d1f365a8ac4adf8c78a1
Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
lathuat1997
2023-03-14 13:30:09 +01:00
parent 8ca0528b5c
commit d51f457df9
@@ -2,7 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
from odoo.tools import float_is_zero
from odoo.tools import float_compare, float_is_zero
class StockMoveLine(models.Model):
@@ -41,8 +41,10 @@ class StockMoveLine(models.Model):
if move_line.state != 'done':
continue
move = move_line.move_id
if float_compare(vals['qty_done'], move_line.qty_done, precision_rounding=move.product_uom.rounding) == 0:
continue
rounding = move.product_id.uom_id.rounding
diff = move.product_uom._compute_quantity(vals['qty_done'] - move_line.qty_done, move.product_id.uom_id)
diff = move.product_uom._compute_quantity(vals['qty_done'] - move_line.qty_done, move.product_id.uom_id, rounding_method='HALF-UP')
if float_is_zero(diff, precision_rounding=rounding):
continue
self._create_correction_svl(move, diff)