Bug Add physical lots
This commit is contained in:
@@ -297,10 +297,24 @@ class Fee(ModelSQL,ModelView):
|
|||||||
if self.line:
|
if self.line:
|
||||||
return self.line.lots
|
return self.line.lots
|
||||||
if self.shipment_in:
|
if self.shipment_in:
|
||||||
|
LotQt = Pool().get('lot.qt')
|
||||||
lots = Lot.search([('lot_shipment_in','=',self.shipment_in.id)])
|
lots = Lot.search([('lot_shipment_in','=',self.shipment_in.id)])
|
||||||
logger.info("LOTSDOMAIN:%s",lots)
|
logger.info("LOTSDOMAIN:%s",lots)
|
||||||
if lots:
|
domain_lots = []
|
||||||
return lots + [lots[0].getVlot_p()]
|
seen = set()
|
||||||
|
for lot in lots:
|
||||||
|
lot_id = getattr(lot, 'id', None)
|
||||||
|
if lot_id not in seen:
|
||||||
|
domain_lots.append(lot)
|
||||||
|
seen.add(lot_id)
|
||||||
|
for lqt in LotQt.search(['lot_shipment_in','=',self.shipment_in.id]):
|
||||||
|
lot = getattr(lqt, 'lot_p', None)
|
||||||
|
lot_id = getattr(lot, 'id', None)
|
||||||
|
if lot and lot_id not in seen:
|
||||||
|
domain_lots.append(lot)
|
||||||
|
seen.add(lot_id)
|
||||||
|
if domain_lots:
|
||||||
|
return domain_lots
|
||||||
if self.shipment_internal:
|
if self.shipment_internal:
|
||||||
return Lot.search([('lot_shipment_internal','=',self.shipment_internal.id)])
|
return Lot.search([('lot_shipment_internal','=',self.shipment_internal.id)])
|
||||||
if self.shipment_out:
|
if self.shipment_out:
|
||||||
|
|||||||
@@ -2332,6 +2332,37 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
self.assertEqual(fee.quantity, Decimal('40.00000'))
|
self.assertEqual(fee.quantity, Decimal('40.00000'))
|
||||||
save.assert_called_once_with([fee])
|
save.assert_called_once_with([fee])
|
||||||
|
|
||||||
|
def test_shipment_fee_lot_domain_keeps_open_virtual_lots(self):
|
||||||
|
'shipment fee lot domain keeps virtual lots after partial physical add'
|
||||||
|
Fee = Pool().get('fee.fee')
|
||||||
|
fee = Fee()
|
||||||
|
fee.line = None
|
||||||
|
fee.sale_line = None
|
||||||
|
fee.shipment_in = Mock(id=7)
|
||||||
|
fee.shipment_internal = None
|
||||||
|
fee.shipment_out = None
|
||||||
|
physical = Mock(id=2599, lot_type='physic')
|
||||||
|
virtual_a = Mock(id=2666, lot_type='virtual')
|
||||||
|
virtual_b = Mock(id=2623, lot_type='virtual')
|
||||||
|
physical.getVlot_p.return_value = virtual_a
|
||||||
|
Lot = Mock()
|
||||||
|
Lot.search.return_value = [physical]
|
||||||
|
LotQt = Mock()
|
||||||
|
LotQt.search.return_value = [
|
||||||
|
Mock(lot_p=virtual_a),
|
||||||
|
Mock(lot_p=virtual_b),
|
||||||
|
]
|
||||||
|
|
||||||
|
with patch('trytond.modules.purchase_trade.fee.Pool') as PoolMock:
|
||||||
|
PoolMock.return_value.get.side_effect = lambda name: {
|
||||||
|
'lot.lot': Lot,
|
||||||
|
'lot.qt': LotQt,
|
||||||
|
}[name]
|
||||||
|
|
||||||
|
lots = fee.get_lots(None)
|
||||||
|
|
||||||
|
self.assertEqual(lots, [physical, virtual_a, virtual_b])
|
||||||
|
|
||||||
def test_fee_ppack_auto_sync_keeps_auto_quantity(self):
|
def test_fee_ppack_auto_sync_keeps_auto_quantity(self):
|
||||||
'per packing auto fee keeps the on-change quantity on save'
|
'per packing auto fee keeps the on-change quantity on save'
|
||||||
Fee = Pool().get('fee.fee')
|
Fee = Pool().get('fee.fee')
|
||||||
|
|||||||
Reference in New Issue
Block a user