[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.
This commit is contained in:
Pedro M. Baeza
2021-12-18 15:20:21 +01:00
committed by Nikolaus Weingartmair
parent f0360134d3
commit 0484db0694

View File

@@ -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)}
)
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([])