Targeted Qt
This commit is contained in:
@@ -2965,6 +2965,43 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
line.get_tolerance_used('tolerance_used'),
|
||||
Decimal('-5.00000'))
|
||||
|
||||
def test_purchase_line_targeted_qt_blocks_above_tolerance(self):
|
||||
'purchase line targeted quantity must stay inside tolerance bounds'
|
||||
physical = Mock(lot_type='physic')
|
||||
physical.get_current_quantity_converted.return_value = Decimal('111')
|
||||
line = purchase_module.Line()
|
||||
line.quantity_theorical = Decimal('100')
|
||||
line.quantity = Decimal('100')
|
||||
line.lots = [physical]
|
||||
line.inherit_tol = False
|
||||
line.tol_min = Decimal('5')
|
||||
line.tol_max = Decimal('10')
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
line.check_targeted_qt_tolerance()
|
||||
|
||||
def test_sale_line_targeted_qt_blocks_below_tolerance(self):
|
||||
'sale line targeted quantity must not fall below tolerance minimum'
|
||||
unit = Mock()
|
||||
virtual = Mock(id=20, lot_type='virtual')
|
||||
line = sale_module.SaleLine()
|
||||
line.unit = unit
|
||||
line.quantity_theorical = Decimal('100')
|
||||
line.quantity = Decimal('100')
|
||||
line.lots = [virtual]
|
||||
line.inherit_tol = False
|
||||
line.tol_min = Decimal('5')
|
||||
line.tol_max = Decimal('10')
|
||||
lot_qt_model = Mock()
|
||||
lot_qt_model.search.return_value = [
|
||||
Mock(lot_quantity=Decimal('-94'), lot_unit=unit)]
|
||||
pool = Mock()
|
||||
pool.get.return_value = lot_qt_model
|
||||
|
||||
with patch.object(sale_module, 'Pool', return_value=pool):
|
||||
with self.assertRaises(UserError):
|
||||
line.check_targeted_qt_tolerance()
|
||||
|
||||
def test_lot_context_group_defaults_to_all(self):
|
||||
'lots management opens without grouping by physical lot'
|
||||
self.assertEqual(lot_module.LotContext.default_group(), 'all')
|
||||
|
||||
Reference in New Issue
Block a user