From 2ce1624373df44bbeb4ce647444019b1072639d5 Mon Sep 17 00:00:00 2001 From: GuillemCForgeFlow Date: Tue, 9 Aug 2022 14:12:28 +0200 Subject: [PATCH 1/2] [FIX]stock_location_route_descriptioin: name_get calculation --- .../models/stock_location_route.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/stock_location_route_description/models/stock_location_route.py b/stock_location_route_description/models/stock_location_route.py index 49cd030f1..f4c4aeb76 100644 --- a/stock_location_route_description/models/stock_location_route.py +++ b/stock_location_route_description/models/stock_location_route.py @@ -10,16 +10,14 @@ class StockLocationRoute(models.Model): description = fields.Char(translate=True) def name_get(self): - result = [] if self.env.context.get("show_description", False): + result = [] for rec in self: + name = "" if rec.description: - rec.display_name = rec.name + ": " + rec.description + name = rec.name + ": " + rec.description else: - rec.display_name = rec.name - result.append((rec.id, rec.display_name)) - else: - for rec in self: - rec.display_name = rec.name - return super(StockLocationRoute, self).name_get() - return result + name = rec.name + result.append((rec.id, name)) + return result + return super().name_get() From 88156ee2bae0a1032743616c6d8786ad986c41ef Mon Sep 17 00:00:00 2001 From: JordiMForgeFlow Date: Tue, 9 Aug 2022 15:01:58 +0200 Subject: [PATCH 2/2] [FIX] stock_location_route_description: fix test --- .../tests/test_stock_location_route_description.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stock_location_route_description/tests/test_stock_location_route_description.py b/stock_location_route_description/tests/test_stock_location_route_description.py index 504e1b7bc..46ca56eac 100644 --- a/stock_location_route_description/tests/test_stock_location_route_description.py +++ b/stock_location_route_description/tests/test_stock_location_route_description.py @@ -7,7 +7,6 @@ from odoo.tests.common import TransactionCase class TestStockLocationRouteDescription(TransactionCase): def setUp(self, *args, **kwargs): super(TestStockLocationRouteDescription, self).setUp(*args, **kwargs) - self.model_stock_location_route = self.env["stock.location.route"] def test_display_name_stock_location_route(self): @@ -18,6 +17,6 @@ class TestStockLocationRouteDescription(TransactionCase): {"name": "Test Route", "description": "Test Description"} ) self.assertEqual(route.display_name, route.name) - route.with_context(show_description=True).name_get() name_description = route.name + ": " + route.description + route.with_context(show_description=True)._compute_display_name() self.assertEqual(route.display_name, name_description)