Go to matching action
This commit is contained in:
@@ -2722,6 +2722,69 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
with self.assertRaises(UserError):
|
||||
lot_module.LotQt.match_lots([purchase_lot], [])
|
||||
|
||||
def test_go_matching_defaults_selected_open_lot_qts(self):
|
||||
'go to matching only preloads selected unmatched open lot.qt rows'
|
||||
purchase = Mock(id=10, party=Mock(id=20))
|
||||
sale = Mock(id=30, party=Mock(id=40))
|
||||
product = Mock(id=50)
|
||||
purchase_lot = Mock(
|
||||
id=101, line=Mock(purchase=purchase), sale_line=None,
|
||||
lot_type='virtual', lot_product=product)
|
||||
sale_lot = Mock(
|
||||
id=102, line=None, sale_line=Mock(sale=sale),
|
||||
lot_type='virtual', lot_product=product)
|
||||
matched_sale_lot = Mock(
|
||||
id=103, line=None, sale_line=Mock(sale=sale),
|
||||
lot_type='virtual', lot_product=product)
|
||||
lot_qts = {
|
||||
1: Mock(
|
||||
id=1, lot_p=purchase_lot, lot_s=None,
|
||||
lot_quantity=Decimal('100'),
|
||||
lot_shipment_in=None, lot_shipment_internal=None,
|
||||
lot_shipment_out=None),
|
||||
2: 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),
|
||||
3: Mock(
|
||||
id=3, lot_p=purchase_lot, lot_s=matched_sale_lot,
|
||||
lot_quantity=Decimal('20'),
|
||||
lot_shipment_in=None, lot_shipment_internal=None,
|
||||
lot_shipment_out=None),
|
||||
}
|
||||
|
||||
class LotQtMock:
|
||||
def __call__(self, _id):
|
||||
return lot_qts[_id]
|
||||
|
||||
pool = Mock()
|
||||
pool.get.side_effect = (
|
||||
lambda name: LotQtMock() if name == 'lot.qt' else Mock())
|
||||
transaction = Mock()
|
||||
transaction.context = {
|
||||
'active_ids': [10000001, 10000002, 10000003],
|
||||
}
|
||||
|
||||
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(result['qt_type'], 'all')
|
||||
self.assertEqual(len(result['lot_p']), 1)
|
||||
self.assertEqual(len(result['lot_s']), 1)
|
||||
self.assertEqual(result['lot_p'][0]['lot_r_id'], 1)
|
||||
self.assertEqual(result['lot_p'][0]['lot_quantity'], Decimal('100'))
|
||||
self.assertEqual(result['lot_p'][0]['lot_cp'], 20)
|
||||
self.assertEqual(result['lot_s'][0]['lot_r_id'], 2)
|
||||
self.assertEqual(result['lot_s'][0]['lot_quantity'], Decimal('80'))
|
||||
self.assertEqual(result['lot_s'][0]['lot_cp'], 40)
|
||||
|
||||
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')
|
||||
|
||||
def test_contract_detail_defaults_sale_locations_from_dropship_purchase(self):
|
||||
'create contracts copies supplier-to-customer locations from purchase to sale'
|
||||
supplier = Mock(id=1, type='supplier')
|
||||
|
||||
Reference in New Issue
Block a user