Go to matching
This commit is contained in:
@@ -3417,6 +3417,77 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(result['lot_s'][0]['lot_qt_max'], Decimal('80.00000'))
|
||||
self.assertEqual(result['lot_s'][0]['lot_cp'], 40)
|
||||
|
||||
def test_go_matching_defaults_selected_physical_purchase_lot(self):
|
||||
'go to matching preloads selected unmatched physical purchase lots'
|
||||
purchase = Mock(id=10, party=Mock(id=20))
|
||||
sale = Mock(id=30, party=Mock(id=40))
|
||||
product = Mock(id=50)
|
||||
physical_lot = Mock(
|
||||
id=101,
|
||||
line=Mock(
|
||||
purchase=purchase, inherit_tol=False,
|
||||
quantity_theorical=Decimal('100'),
|
||||
targeted_qt=Decimal('96'), tol_min=0, tol_max=0),
|
||||
sale_line=None,
|
||||
lot_type='physic',
|
||||
lot_product=product,
|
||||
lot_shipment_in=None,
|
||||
lot_shipment_internal=None,
|
||||
lot_shipment_out=None)
|
||||
physical_lot.get_current_quantity_converted.return_value = (
|
||||
Decimal('70'))
|
||||
sale_lot = Mock(
|
||||
id=102, line=None,
|
||||
sale_line=Mock(
|
||||
sale=sale, inherit_tol=False,
|
||||
quantity_theorical=Decimal('80'),
|
||||
targeted_qt=Decimal('84'), tol_min=0, tol_max=0),
|
||||
lot_type='virtual', lot_product=product)
|
||||
sale_lqt = Mock(
|
||||
id=2, lot_p=None, lot_s=sale_lot,
|
||||
lot_quantity=Decimal('80'),
|
||||
lot_shipment_in=None, lot_shipment_internal=None,
|
||||
lot_shipment_out=None)
|
||||
|
||||
class LotQtMock:
|
||||
def __call__(self, _id):
|
||||
return sale_lqt
|
||||
|
||||
class LotMock:
|
||||
def __call__(self, _id):
|
||||
return physical_lot
|
||||
|
||||
pool = Mock()
|
||||
pool.get.side_effect = (
|
||||
lambda name: LotQtMock() if name == 'lot.qt' else LotMock())
|
||||
transaction = Mock()
|
||||
transaction.context = {
|
||||
'active_ids': [101, 10000002],
|
||||
}
|
||||
|
||||
with patch.object(lot_module, 'Pool', return_value=pool):
|
||||
with patch.object(
|
||||
lot_module, 'Transaction', return_value=transaction):
|
||||
result = lot_module.LotGoMatching().default_match([])
|
||||
|
||||
self.assertEqual(len(result['lot_p']), 1)
|
||||
self.assertEqual(len(result['lot_s']), 1)
|
||||
self.assertEqual(result['lot_p'][0]['lot_id'], 101)
|
||||
self.assertIsNone(result['lot_p'][0]['lot_r_id'])
|
||||
self.assertEqual(result['lot_p'][0]['lot_type'], 'physic')
|
||||
self.assertEqual(result['lot_p'][0]['lot_quantity'], Decimal('70'))
|
||||
self.assertEqual(result['lot_p'][0]['lot_targeted_qt'], Decimal('96'))
|
||||
self.assertEqual(result['lot_p'][0]['lot_cp'], 20)
|
||||
self.assertEqual(result['lot_s'][0]['lot_r_id'], 2)
|
||||
|
||||
def test_go_matching_requires_purchase_and_sale_selection(self):
|
||||
'go to matching requires one purchase and one sale row'
|
||||
wizard = lot_module.LotGoMatching()
|
||||
wizard.match = Mock(lot_p=[], lot_s=[Mock()])
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
wizard.transition_matching()
|
||||
|
||||
def test_purchase_tolerance_used_is_weighted_line_average(self):
|
||||
'purchase tolerance gauge averages line gauges by theoretical quantity'
|
||||
unit = Mock()
|
||||
|
||||
Reference in New Issue
Block a user