From 0484db069422bf34cac1a472c0ddb58e981a911e Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sat, 18 Dec 2021 15:20:21 +0100 Subject: [PATCH] [FIX] rma: Adjust hook for existing values If rma_in_type_id or rma_out_type_id are already set, then the hook fails. With this alternative code, we avoid it and clean it for being clearer. --- rma/hooks.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rma/hooks.py b/rma/hooks.py index 9aafcaf0..ed625906 100644 --- a/rma/hooks.py +++ b/rma/hooks.py @@ -56,15 +56,10 @@ def post_init_hook(cr, registry): ) data[picking_type] = stock_picking_type.create(values).id - rma_out_type = stock_picking_type.browse(data["rma_out_type_id"]) - rma_out_type.write( - {"return_picking_type_id": data.get("rma_in_type_id", False)} - ) - rma_in_type = stock_picking_type.browse(data["rma_in_type_id"]) - rma_in_type.write( - {"return_picking_type_id": data.get("rma_out_type_id", False)} - ) - whs.write(data) + if data: + whs.write(data) + whs.rma_in_type_id.return_picking_type_id = whs.rma_out_type_id.id + whs.rma_out_type_id.return_picking_type_id = whs.rma_in_type_id.id # Create rma locations and picking types warehouses = env["stock.warehouse"].search([])