Add test Move assign_try skips to_location

issue7856
review66541002
This commit is contained in:
Cédric Krier committed 2019-02-18 18:35:23 +01:00
1 parent e3b6c3559d
commit 0498c4cdd5
1 file changed
+53
+53
View File
@@ -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"