Bug Add Physical
This commit is contained in:
@@ -80,6 +80,58 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
strategy.get_mtm(line, Decimal('10')),
|
||||
Decimal('250.00'))
|
||||
|
||||
@with_transaction()
|
||||
def test_add_physical_lot_defaults_hidden_premium_and_chunk_key(self):
|
||||
'add physical lot works when hidden tree fields are not loaded'
|
||||
LotQt = Pool().get('lot.qt')
|
||||
saved_lots = []
|
||||
|
||||
class FakeLot:
|
||||
def __init__(self):
|
||||
self.sale_line = None
|
||||
self.id = 1
|
||||
|
||||
def set_current_quantity(self, quantity, gross_quantity, type_):
|
||||
self.quantity = quantity
|
||||
self.gross_quantity = gross_quantity
|
||||
self.quantity_type = type_
|
||||
|
||||
def get_current_quantity_converted(self):
|
||||
return self.quantity
|
||||
|
||||
@classmethod
|
||||
def save(cls, lots):
|
||||
saved_lots.extend(lots)
|
||||
|
||||
class AddLine:
|
||||
lot_qt = Decimal('10')
|
||||
lot_unit = Mock()
|
||||
lot_unit_line = Mock()
|
||||
lot_quantity = Decimal('10')
|
||||
lot_gross_quantity = Decimal('11')
|
||||
|
||||
line = Mock(product=Mock(), fees=[])
|
||||
line.purchase = Mock()
|
||||
lqt = LotQt()
|
||||
lqt.lot_p = Mock(line=line)
|
||||
lqt.lot_s = None
|
||||
lqt.lot_shipment_in = None
|
||||
lqt.lot_shipment_internal = None
|
||||
lqt.lot_shipment_out = None
|
||||
|
||||
with patch('trytond.modules.purchase_trade.lot.Pool') as PoolMock:
|
||||
PoolMock.return_value.get.side_effect = lambda name: {
|
||||
'lot.lot': FakeLot,
|
||||
'fee.lots': Mock(),
|
||||
'purchase.purchase': Mock(),
|
||||
}[name]
|
||||
|
||||
lqt.add_physical_lot(AddLine())
|
||||
|
||||
self.assertEqual(len(saved_lots), 1)
|
||||
self.assertIsNone(saved_lots[0].lot_chunk_key)
|
||||
self.assertEqual(saved_lots[0].lot_premium, Decimal(0))
|
||||
|
||||
def test_get_strategy_mtm_price_applies_component_ratio(self):
|
||||
'strategy mtm price applies component ratios'
|
||||
strategy = Mock(
|
||||
|
||||
Reference in New Issue
Block a user