From 34073750ed9e9dff954119295cae4cc754dde6b1 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Wed, 22 Mar 2017 11:14:45 +0100 Subject: [PATCH] Avoid computation for assign_try with no moves issue6366 review31201002 --- move.py | 3 +++ tests/test_stock.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/move.py b/move.py index b46d0085fd..8bf194e993 100644 --- a/move.py +++ b/move.py @@ -783,6 +783,9 @@ class Move(Workflow, ModelSQL, ModelView): database = transaction.database connection = transaction.connection + if not moves: + return True + if with_childs: locations = Location.search([ ('parent', 'child_of', diff --git a/tests/test_stock.py b/tests/test_stock.py index c0f3c9c180..63702e800e 100644 --- a/tests/test_stock.py +++ b/tests/test_stock.py @@ -786,6 +786,14 @@ class StockTestCase(ModuleTestCase): self.assertFalse(Move.assign_try(moves)) self.assertEqual([m.state for m in moves], ['assigned', 'draft']) + @with_transaction() + def test_assign_without_moves(self): + "Test Move assign_try with empty moves" + pool = Pool() + Move = pool.get('stock.move') + + self.assertTrue(Move.assign_try([])) + def suite(): suite = trytond.tests.test_tryton.suite()