diff --git a/tests/test_stock.py b/tests/test_stock.py index a877a7115c..fecbec97ee 100644 --- a/tests/test_stock.py +++ b/tests/test_stock.py @@ -1075,6 +1075,59 @@ class StockTestCase(ModuleTestCase): self.assertFalse(Move.assign_try(moves)) self.assertEqual([m.state for m in moves], ['assigned', 'draft']) + @with_transaction() + def test_assign_try_skip_to_location(self): + "Test Move assign_try skip to_location" + pool = Pool() + Template = pool.get('product.template') + Product = pool.get('product.product') + Uom = pool.get('product.uom') + Location = pool.get('stock.location') + Move = pool.get('stock.move') + + uom, = Uom.search([('name', '=', 'Meter')]) + template = Template( + name='Test Move.assign_try', + type='goods', + list_price=Decimal(1), + default_uom=uom, + ) + template.save() + product = Product(template=template.id) + product.save() + + supplier, = Location.search([('code', '=', 'SUP')]) + storage, = Location.search([('code', '=', 'STO')]) + child, = Location.copy([storage], default={'parent': storage.id}) + + company = create_company() + with set_company(company): + move, = Move.create([{ + 'product': product.id, + 'uom': uom.id, + 'quantity': 1, + 'from_location': supplier.id, + 'to_location': child.id, + 'company': company.id, + 'unit_price': Decimal(1), + 'currency': company.currency.id, + }]) + Move.do([move]) + + move, = Move.create([{ + 'product': product.id, + 'uom': uom.id, + 'quantity': 1, + 'from_location': storage.id, + 'to_location': child.id, + 'company': company.id, + 'unit_price': Decimal(1), + 'currency': company.currency.id, + }]) + + self.assertFalse(Move.assign_try([move])) + self.assertEqual(move.state, 'draft') + @with_transaction() def test_assign_without_moves(self): "Test Move assign_try with empty moves"