[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.
This commit is contained in:
Pedro M. Baeza
2021-09-06 08:39:53 +02:00
committed by Nikolaus Weingartmair
parent 44bec64b87
commit 09abc9d3b5
2 changed files with 11 additions and 12 deletions

View File

@@ -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()

View File

@@ -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