Check 2 stock move matchings were created
-
!python {model: stock.picking}: |
- if len(self.browse(cr, uid, ref("outgoing_fifo_shipment")).move_lines[0].matching_ids_out) != 2:
- print 'Should have created 2 matchings'
+ assert len(self.browse(cr, uid, ref("outgoing_fifo_shipment")).move_lines[0].matching_ids_out) == 2, "It should have created 2 "
-
Check product standard price changed to 65.0
-
-
!python {model: stock.partial.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_usd")).picking_ids
- print pick_ids
- print uid, context
- print self.pool.get('res.users').browse(cr, uid, uid).company_id.id
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
- print partial_id
self.do_partial(cr, uid, [partial_id])
-
We create delivery order of 49.500 kg
Check rounded price is 102 euro = (30 kg * )
-
!python {model: product.product}: |
- print round(self.browse(cr, uid, ref("product_fifo_icecream")).standard_price, 2)
assert round(self.browse(cr, uid, ref("product_fifo_icecream")).standard_price) == 102
-
- Print price
--
- !python {model: product.product}: |
- print self.browse(cr, uid, ref("product_fifo_icecream")).standard_price
- print self.browse(cr, uid, ref("product_fifo_icecream")).qty_available
- list = self.pool.get("stock.move").search(cr, uid, [('product_id','=', ref("product_fifo_icecream"))])
- for move in self.pool.get("stock.move").browse(cr, uid, list):
- print move.price_unit, move.product_qty, move.qty_remaining, move.type, move.date
--
Do a delivery of an extra 10 kg
-
!record {model: stock.picking, id: outgoing_fifo_shipment_ret}:
!python {model: product.product}: |
assert round(self.browse(cr, uid, ref("product_fifo_icecream")).standard_price) == round(150.0 / 1.2834)
-
- Print price
--
- !python {model: product.product}: |
- print self.browse(cr, uid, ref("product_fifo_icecream")).standard_price
- print self.browse(cr, uid, ref("product_fifo_icecream")).qty_available
- print self.browse(cr, uid, ref("product_fifo_icecream"), context={'force_company': 1}).qty_available
- list = self.pool.get("stock.move").search(cr, uid, [('product_id','=', ref("product_fifo_icecream"))])
- for move in self.pool.get("stock.move").browse(cr, uid, list):
- print move.price_unit, move.product_qty, move.qty_remaining, move.type, move.date
--
Let us create some outs to get negative stock. Create outpicking. We create delivery order of 200 kg, but will pick only 100 kg
-
!record {model: stock.picking, id: outgoing_fifo_shipment_neg}:
self.pool.get("stock.partial.picking.line").write(cr, uid, [line.id], {'quantity':50})
self.do_partial(cr, uid, [partial_id])
-
- Print price
--
- !python {model: product.product}: |
- print self.browse(cr, uid, ref("product_fifo_icecream")).standard_price
- print self.browse(cr, uid, ref("product_fifo_icecream")).qty_available
- print self.browse(cr, uid, ref("product_fifo_icecream"), context={'force_company': 1}).qty_available
- list = self.pool.get("stock.move").search(cr, uid, [('product_id','=', ref("product_fifo_icecream"))])
- for move in self.pool.get("stock.move").browse(cr, uid, list):
- print move.price_unit, move.product_qty, move.qty_remaining, move.type, move.date
--
Receive purchase order with 50 kg FIFO Ice Cream at 50 euro/kg
-
!record {model: purchase.order, id: purchase_order_fifo_neg}:
The price of the product should have changed back to 65.0
-
!python {model: product.product}: |
- print self.browse(cr, uid, ref("product_fifo_icecream")).standard_price
- print self.browse(cr, uid, ref("product_fifo_icecream")).qty_available
- print self.browse(cr, uid, ref("product_fifo_icecream"), context={'force_company': 1}).qty_available
- list = self.pool.get("stock.move").search(cr, uid, [('product_id','=', ref("product_fifo_icecream"))], order='date')
- for move in self.pool.get("stock.move").browse(cr, uid, list):
- print move.price_unit, move.product_qty, move.qty_remaining, move.type, move.date
\ No newline at end of file
+ assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 65.0
\ No newline at end of file