diff --git a/location.py b/location.py index ddee609..7eed177 100644 --- a/location.py +++ b/location.py @@ -10,8 +10,9 @@ class Location(ModelSQL, ModelView): __name__ = 'stock.location' warehouse = fields.Function(fields.Many2One('stock.location', 'Warehouse', - on_change_with=['parent'], - states={'invisible': Not(In(Eval('type'), ['storage', 'view']))}, + states={ + 'invisible': Not(In(Eval('type'), ['storage', 'view'])) + }, depends=['type']), 'get_warehouse', searcher='search_warehouse') @@ -23,6 +24,7 @@ class Location(ModelSQL, ModelView): 'The Storage location must be unique.'), ] + @fields.depends('parent') def on_change_with_warehouse(self, name=None): if (not self.id or self.type not in ('storage', 'view') or not self.parent): diff --git a/tests/test_stock_location_warehouse.py b/tests/test_stock_location_warehouse.py index 14337ca..ca04f5d 100644 --- a/tests/test_stock_location_warehouse.py +++ b/tests/test_stock_location_warehouse.py @@ -1,35 +1,22 @@ #The COPYRIGHT file at the top level of this repository contains the full #copyright notices and license terms. -import sys -import os -DIR = os.path.abspath(os.path.normpath(os.path.join(__file__, - '..', '..', '..', '..', '..', 'trytond'))) -if os.path.isdir(DIR): - sys.path.insert(0, os.path.dirname(DIR)) - import unittest import trytond.tests.test_tryton from trytond.tests.test_tryton import test_view, test_depends class StockLocationWarehouseTestCase(unittest.TestCase): - ''' - Test stock_location_warehouse module. - ''' + 'Test stock_location_warehouse module' def setUp(self): trytond.tests.test_tryton.install_module('stock_location_warehouse') def test0005views(self): - ''' - Test views. - ''' + 'Test views' test_view('stock_location_warehouse') def test0006depends(self): - ''' - Test depends. - ''' + 'Test depends' test_depends() @@ -38,6 +25,3 @@ def suite(): suite.addTests(unittest.TestLoader().loadTestsFromTestCase( StockLocationWarehouseTestCase)) return suite - -if __name__ == '__main__': - unittest.TextTestRunner(verbosity=2).run(suite()) diff --git a/tryton.cfg b/tryton.cfg index 1353690..0589b2d 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=3.0.0 +version=3.2.0 depends: ir stock