From 45d9d6d3241efb766a54ca819173af7a418ae4ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BA=B7ng=20V=C4=83n=20L=E1=BB=99c?= Date: Thu, 9 Mar 2023 13:58:57 +0000 Subject: [PATCH] [FIX] stock: Error if warehouse_id is given to the form view If the developer wants to give warehouse_id form view, when create new location, there will be an error in the compute function because it use function split() with field parent_path has no value closes odoo/odoo#115103 X-original-commit: 4d9b2ec6c85a178898bd81fe45bb0fcd3ba1a901 Signed-off-by: William Henrotin (whe) --- addons/stock/models/stock_location.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index 4cbaa0e54e3..a3724ecef2b 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -152,6 +152,8 @@ class Location(models.Model): view_by_wh = OrderedDict((wh.view_location_id.id, wh.id) for wh in warehouses) self.warehouse_id = False for loc in self: + if not loc.parent_path: + continue path = set(int(loc_id) for loc_id in loc.parent_path.split('/')[:-1]) for view_location_id in view_by_wh: if view_location_id in path: