From 09abc9d3b5636ce1e77c769fa2f34e5974987edf Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 6 Sep 2021 08:39:53 +0200 Subject: [PATCH] [FIX] rma: Use Form to avoid UoM change invalid check Since odoo/odoo#75823, the wizard lines have the field uom_id related to move.product_uom and readonly=False, so if you call directly to wiz.onchage_picking_id a write in stock move is executed and the warning raises, although we don't really do any UoM change. We avoid it using the `Form` to perform the wizard update. --- rma/models/rma.py | 11 +++++------ rma/tests/test_rma.py | 12 ++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/rma/models/rma.py b/rma/models/rma.py index d6d35a24..129ff210 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -895,15 +895,14 @@ class Rma(models.Model): location_id=self.location_id.id, picking_id=self.picking_id.id, ) - return_wizard = ( - self.env["stock.return.picking"] - .with_context( - active_id=self.picking_id.id, + stock_return_picking_form = Form( + self.env["stock.return.picking"].with_context( active_ids=self.picking_id.ids, + active_id=self.picking_id.id, + active_model="stock.picking", ) - .create(create_vals) ) - return_wizard._onchange_picking_id() + return_wizard = stock_return_picking_form.save() return_wizard.product_return_moves.filtered( lambda r: r.move_id != self.move_id ).unlink() diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py index d38cd3e1..ab0ca6da 100644 --- a/rma/tests/test_rma.py +++ b/rma/tests/test_rma.py @@ -571,15 +571,15 @@ class TestRma(SavepointCase): def test_rma_from_picking_return(self): # Create a return from a delivery picking origin_delivery = self._create_delivery() - return_wizard = ( - self.env["stock.return.picking"] - .with_context( - active_id=origin_delivery.id, + stock_return_picking_form = Form( + self.env["stock.return.picking"].with_context( active_ids=origin_delivery.ids, + active_id=origin_delivery.id, + active_model="stock.picking", ) - .create({"create_rma": True, "picking_id": origin_delivery.id}) ) - return_wizard._onchange_picking_id() + stock_return_picking_form.create_rma = True + return_wizard = stock_return_picking_form.save() picking_action = return_wizard.create_returns() # Each origin move is linked to a different RMA origin_moves = origin_delivery.move_lines