From eb5fb371088aec111f4b4111fdcecb0b28077409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Fri, 28 Jun 2024 08:46:45 +0200 Subject: [PATCH 1/2] [FIX] rma: Make the quantity comparison correctly (with precision_digits) Fixes https://github.com/OCA/rma/issues/398 --- rma/models/stock_move.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rma/models/stock_move.py b/rma/models/stock_move.py index ee788924..eaa41114 100644 --- a/rma/models/stock_move.py +++ b/rma/models/stock_move.py @@ -4,6 +4,7 @@ from odoo import _, api, fields, models from odoo.exceptions import ValidationError +from odoo.tools import float_compare class StockMove(models.Model): @@ -60,7 +61,18 @@ class StockMove(models.Model): """ for move in self.filtered(lambda r: r.state not in ("done", "cancel")): rma_receiver = move.sudo().rma_receiver_ids - if rma_receiver and move.quantity_done != 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_done, + rma_receiver.product_uom_qty, + precision_digits=qty_prec, + ) + != 0 + ): raise ValidationError( _( "The quantity done for the product '%(id)s' must " From e4f26a6d97dc576e54723e1f9f5be54341295ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Fri, 28 Jun 2024 09:12:03 +0200 Subject: [PATCH 2/2] [FIX] rma: Change code to get the correct rmas (move_ids.rma_ids) --- rma/models/stock_picking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rma/models/stock_picking.py b/rma/models/stock_picking.py index fa48d578..070cdabd 100644 --- a/rma/models/stock_picking.py +++ b/rma/models/stock_picking.py @@ -31,7 +31,7 @@ class StockPicking(models.Model): def action_view_rma(self): self.ensure_one() action = self.env["ir.actions.act_window"]._for_xml_id("rma.rma_action") - rma = self.move_lines.mapped("rma_ids") + rma = self.move_ids.rma_ids if len(rma) == 1: action.update( res_id=rma.id,