[FIX] rma: Make the quantity comparison correctly (with precision_digits)

Fixes https://github.com/OCA/rma/issues/398
This commit is contained in:
Víctor Martínez
2024-06-28 08:46:45 +02:00
parent bba264e4d1
commit b17e230233

View File

@@ -3,6 +3,7 @@
from odoo import _, api, fields, models from odoo import _, api, fields, models
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from odoo.tools import float_compare
class StockMove(models.Model): class StockMove(models.Model):
@@ -59,7 +60,18 @@ class StockMove(models.Model):
""" """
for move in self.filtered(lambda r: r.state not in ("done", "cancel")): for move in self.filtered(lambda r: r.state not in ("done", "cancel")):
rma_receiver = move.sudo().rma_receiver_ids rma_receiver = move.sudo().rma_receiver_ids
if rma_receiver and move.quantity != rma_receiver.product_uom_qty: qty_prec = self.env["decimal.precision"].precision_get(
"Product Unit of Measure"
)
if (
rma_receiver
and float_compare(
move.quantity,
rma_receiver.product_uom_qty,
precision_digits=qty_prec,
)
!= 0
):
raise ValidationError( raise ValidationError(
_( _(
"The quantity done for the product '%(id)s' must " "The quantity done for the product '%(id)s' must "