changeset 0955c4058303 in modules/stock_lot:default
details: https://hg.tryton.org/modules/stock_lot?cmd=changeset;node=0955c4058303
description:
Fill grouping values when assigning move
issue9480
review303951082
diffstat:
tests/test_stock_lot.py | 96 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 0 deletions(-)
diffs (106 lines):
diff -r 0bfcbf88be4d -r 0955c4058303 tests/test_stock_lot.py
--- a/tests/test_stock_lot.py Mon Jul 27 11:02:24 2020 +0200
+++ b/tests/test_stock_lot.py Mon Aug 10 23:30:14 2020 +0200
@@ -220,6 +220,102 @@
self.assertEqual(lot_cache.internal_quantity,
quantities[(lot_cache.location, lot_cache.lot)])
+ @with_transaction
+ def test_assign_try_with_lot(self):
+ "Test Move assign_try with lot"
+ 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')
+ Lot = pool.get('stock.lot')
+
+ uom, = Uom.search([('name', '=', 'Meter')])
+ template = Template(
+ name="Product",
+ 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')])
+ customer, = Location.search([('code', '=', 'CUS')])
+
+ company = create_company()
+ with set_company(company):
+ lot1, lot2 = Lot.create([{
+ 'number': "1",
+ 'product': product.id,
+ }, {
+ 'number': "2",
+ 'product': product.id,
+ }])
+ moves = Move.create([{
+ 'product': product.id,
+ 'lot': lot1.id,
+ 'uom': uom.id,
+ 'quantity': 2,
+ 'from_location': supplier.id,
+ 'to_location': storage.id,
+ 'company': company.id,
+ 'unit_price': Decimal(1),
+ 'currency': company.currency.id,
+ }, {
+ 'product': product.id,
+ 'lot': lot2.id,
+ 'uom': uom.id,
+ 'quantity': 3,
+ 'from_location': supplier.id,
+ 'to_location': storage.id,
+ 'company': company.id,
+ 'unit_price': Decimal(1),
+ 'currency': company.currency.id,
+ }, {
+ 'product': product.id,
+ 'lot': None,
+ 'uom': uom.id,
+ 'quantity': 3,
+ 'from_location': supplier.id,
+ 'to_location': storage.id,
+ 'company': company.id,
+ 'unit_price': Decimal(1),
+ 'currency': company.currency.id,
+ }])
+ Move.do(moves)
+
+ move, = Move.create([{
+ 'product': product.id,
+ 'uom': uom.id,
+ 'quantity': 10,
+ 'from_location': storage.id,
+ 'to_location': customer.id,
+ 'company': company.id,
+ 'unit_price': Decimal(1),
+ 'currency': company.currency.id,
+ }])
+
+ self.assertFalse(
+ Move.assign_try([move], grouping=('product', 'lot')))
+ moves = Move.search([
+ ('product', '=', product.id),
+ ('from_location', '=', storage.id),
+ ('to_location', '=', customer.id),
+ ('company', '=', company.id),
+ ])
+ self.assertEqual(len(moves), 4)
+ self.assertEqual({
+ (m.lot, m.quantity, m.state) for m in moves}, {
+ (lot1, 2, 'assigned'),
+ (lot2, 3, 'assigned'),
+ (None, 1, 'assigned'),
+ (None, 4, 'draft'),
+ })
+
def suite():
suite = trytond.tests.test_tryton.suite()