odoo/addons/stock/test/shipment.yml

65 lines
3.1 KiB
YAML

-
Stock manager can only test whole process related to Shipment, so we check data with stock manager.
-
!context
uid: 'res_users_stock_manager'
-
I confirm incoming move of 50 kgm Ice-cream
-
!python {model: stock.move}: |
incoming_move = self.browse(cr, uid, ref("incomming_shipment_icecream"))
self.action_confirm(cr, uid, [incoming_move.id])
-
I receive 40kgm Ice-cream so It will make backorder of incomming shipment for 10 kgm.
-
!python {model: stock.picking}: |
pick = self.browse(cr, uid, ref("incomming_shipment"), context=context)
self.pool.get('stock.pack.operation').create(cr, uid, {
'picking_id': pick.id,
'product_id': ref('product_icecream'),
'product_uom_id': ref('product.product_uom_kgm'),
'product_qty': 40,
'location_id': ref('stock.stock_location_suppliers'),
'location_dest_id': ref('stock.stock_location_14')
})
context.update({'active_model': 'stock.picking', 'active_id': ref('incomming_shipment'), 'active_ids': [ref('incomming_shipment')]})
pick = self.browse(cr, uid, pick.id, context=context)
pick.do_transfer()
-
I check backorder shipment after received partial shipment and check remaining shipment.
-
!python {model: stock.picking}: |
shipment = self.browse(cr, uid, ref("incomming_shipment"))
for move_line in shipment.move_lines:
assert move_line.product_qty == 40, "Qty in shipment does not correspond."
assert move_line.state == 'done', "Move line of shipment should be closed."
backorder_id = self.search(cr, uid, [('backorder_id', '=', ref("incomming_shipment"))],context=context)
backorder = self.browse(cr, uid, backorder_id)[0]
for move_line in backorder.move_lines:
assert move_line.product_qty == 10, "Qty in backorder does not correspond."
assert (move_line.state == 'assigned' or move_line.state == 'waiting' or move_line.state == 'confirmed'), "Move line of backorder should be assigned, confirmed or waiting."
context.update({'active_model': 'stock.picking', 'active_id': backorder_id[0], 'active_ids': backorder_id})
-
I receive the remaining 10kgm Ice-cream from the backorder.
-
!python {model: stock.picking}: |
backorder_id = self.search(cr, uid, [('backorder_id', '=', ref("incomming_shipment"))],context=context)
backorder = self.browse(cr, uid, backorder_id, context=context)[0]
self.pool.get('stock.pack.operation').create(cr, uid, {
'picking_id': backorder.id,
'product_id': ref('product_icecream'),
'product_uom_id': ref('product.product_uom_kgm'),
'product_qty': 10,
'location_id': ref('stock.stock_location_suppliers'),
'location_dest_id': ref('stock.stock_location_14')
})
backorder.do_transfer()
-
I check incomming shipment after receipt.
-
!python {model: stock.picking}: |
shipment = self.browse(cr, uid, self.search(cr, uid, [('backorder_id', '=', ref("incomming_shipment"))]))[0]
assert shipment.state == 'done', "shipment should be close after received."
for move_line in shipment.move_lines:
assert move_line.state == 'done', "Move line should be closed."