SHipment cancel
This commit is contained in:
@@ -969,6 +969,41 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
fee_model.save.assert_not_called()
|
||||
product_model.get_by_name.assert_not_called()
|
||||
|
||||
def test_shipment_started_cancel_deletes_draft_stock_account_moves(self):
|
||||
'started shipment cancel removes draft account moves linked to stock moves'
|
||||
ShipmentIn = Pool().get('stock.shipment.in')
|
||||
draft_move = Mock(state='draft')
|
||||
account_move = Mock()
|
||||
account_move.search.return_value = [draft_move]
|
||||
stock_moves = [Mock(id=10), Mock(id=20)]
|
||||
|
||||
with patch('trytond.modules.purchase_trade.stock.Pool') as PoolMock:
|
||||
PoolMock.return_value.get.return_value = account_move
|
||||
|
||||
ShipmentIn._delete_draft_account_moves_for_stock_moves(stock_moves)
|
||||
|
||||
account_move.search.assert_called_once_with([
|
||||
('origin', 'in', ['stock.move,10', 'stock.move,20']),
|
||||
])
|
||||
account_move.delete.assert_called_once_with([draft_move])
|
||||
|
||||
def test_shipment_started_cancel_refuses_posted_stock_account_moves(self):
|
||||
'started shipment cancel is blocked by posted stock account moves'
|
||||
ShipmentIn = Pool().get('stock.shipment.in')
|
||||
posted_move = Mock(state='posted', rec_name='STJ/1')
|
||||
account_move = Mock()
|
||||
account_move.search.return_value = [posted_move]
|
||||
|
||||
with patch('trytond.modules.purchase_trade.stock.Pool') as PoolMock:
|
||||
PoolMock.return_value.get.return_value = account_move
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
ShipmentIn._delete_draft_account_moves_for_stock_moves([
|
||||
Mock(id=10),
|
||||
])
|
||||
|
||||
account_move.delete.assert_not_called()
|
||||
|
||||
@with_transaction()
|
||||
def test_shipment_in_type_detects_dropship(self):
|
||||
'shipment type is dropship from supplier directly to customer'
|
||||
|
||||
Reference in New Issue
Block a user