details:   https://code.tryton.org/tryton/commit/26b2c5a94b90
branch:    default
user:      Cédric Krier <[email protected]>
date:      Thu May 07 18:36:18 2026 +0200
description:
        Replace warehouse field on location by a property

        The Function field is not efficient so its usage should be reserved to
        server side code only.
diffstat:

 modules/stock/location.py |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 9e8d1bca2c7f -r 26b2c5a94b90 modules/stock/location.py
--- a/modules/stock/location.py Mon Jun 08 09:09:23 2026 +0200
+++ b/modules/stock/location.py Thu May 07 18:36:18 2026 +0200
@@ -82,8 +82,6 @@
         "Flat Children",
         help="Check to enforce a single level of children with no "
         "grandchildren.")
-    warehouse = fields.Function(fields.Many2One('stock.location', 'Warehouse'),
-        'get_warehouse')
     input_location = fields.Many2One(
         "stock.location", "Input", states={
             'invisible': Eval('type') != 'warehouse',
@@ -341,7 +339,8 @@
     def default_type():
         return 'storage'
 
-    def get_warehouse(self, name):
+    @property
+    def warehouse(self):
         # Order by descending left to get the first one in the tree
         with inactive_records():
             locations = self.search([
@@ -349,7 +348,7 @@
                     ('type', '=', 'warehouse'),
                     ], order=[('left', 'DESC')])
         if locations:
-            return locations[0].id
+            return locations[0]
 
     @classmethod
     def get_default_warehouse(cls):

Reply via email to