[FIX] purchase: fifo_price.yml

bzr revid: qdp-launchpad@openerp.com-20130903081924-v8owkq941a18eumb
This commit is contained in:
Quentin (OpenERP) 2013-09-03 10:19:24 +02:00
commit ab07c9cc12
2 changed files with 79 additions and 90 deletions

View File

@ -234,7 +234,7 @@ class purchase_order(osv.osv):
'journal_id': fields.many2one('account.journal', 'Journal'),
'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"),
'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"),
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', help="This will determine picking type of incoming shipment"),
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', help="This will determine picking type of incoming shipment", required=True),
}
_defaults = {
'date_order': fields.date.context_today,

View File

@ -28,6 +28,26 @@
product_uom: product.product_uom_categ_kgm
price_unit: 50.0
name: 'FIFO Ice Cream'
-
I confirm the first purchase order
-
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_fifo1}
-
I check the "Approved" status of purchase order 1
-
!assert {model: purchase.order, id: purchase_order_fifo1}:
- state == 'approved'
-
Process the reception of purchase order 1 and set date
-
!python {model: stock.picking}: |
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo1")).picking_ids[0]
picking_obj.do_partial(context=context)
-
Check the standard price of the product (fifo icecream), that should have not changed because the standard price is supposed to be updated only when goods are going out of the stock
-
!python {model: product.product}: |
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 70.0, 'Standard price should not have changed!'
-
I create a draft Purchase Order for second shipment for 30 kg at 80 euro
-
@ -41,27 +61,6 @@
product_uom: product.product_uom_categ_kgm
price_unit: 80.0
name: 'FIFO Ice Cream'
-
I confirm the first purchase order
-
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_fifo1}
-
I check the "Approved" status of purchase order 1
-
!assert {model: purchase.order, id: purchase_order_fifo1}:
- state == 'approved'
-
Process the reception of purchase order 1 and set date
-
!python {model: stock.partial.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo1")).picking_ids
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
self.do_partial(cr, uid, [partial_id])
-
Check the standard price of the product (fifo icecream)
-
!python {model: product.product}: |
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 70.0, 'Standard price should not have changed!'
-
I confirm the second purchase order
-
@ -69,26 +68,11 @@
-
Process the reception of purchase order 2
-
!python {model: stock.partial.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo2")).picking_ids
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
self.do_partial(cr, uid, [partial_id])
!python {model: stock.picking}: |
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo2")).picking_ids[0]
picking_obj.do_partial(context=context)
-
A purchase order towards the Chicago shop TODO code for receiving
-
!record {model: purchase.order, id: purchase_order_fifo_comp}:
partner_id: base.res_partner_3
company_id: stock.res_company_1
location_id: stock.stock_location_shop0
pricelist_id: 1
order_line:
- product_id: product_fifo_icecream
product_qty: 35.0
product_uom: product.product_uom_categ_kgm
price_unit: 50.0
name: 'FIFO Ice Cream'
-
Check the standard price should not have changed
Check the standard price of the product, that should have not changed because the standard price is supposed to be updated only when goods are going out of the stock
-
!python {model: product.product}: |
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 70.0, 'Standard price as fifo price of second reception incorrect!'
@ -96,7 +80,7 @@
Let us send some goods
-
!record {model: stock.picking, id: outgoing_fifo_shipment}:
type: out
picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@ -105,7 +89,9 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 20.0
type: out
location_id: stock.stock_location_stock
location_dest_id: stock.stock_location_customers
picking_type_id: stock.picking_type_out
-
I assign this outgoing shipment
-
@ -114,11 +100,11 @@
-
Process the delivery of the outgoing shipment
-
!python {model: stock.partial.picking}: |
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment")], 'default_type':'out'})
self.do_partial(cr, uid, [partial_id])
!python {model: stock.picking}: |
pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment"))
pick_obj.do_partial(context=context)
-
Check product standard price changed to 65.0
Check product standard price changed to 65.0 (because last outgoing shipment was made of 10 kg at 50€ and 10 kg at 80€)
-
!python {model: product.product}: |
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 65.0
@ -126,7 +112,7 @@
Do a delivery of an extra 500 g (delivery order)
-
!record {model: stock.picking, id: outgoing_fifo_shipment_uom}:
type: out
picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@ -134,8 +120,10 @@
picking_id: outgoing_fifo_shipment_uom
product_id: product_fifo_icecream
product_uom: product.product_uom_gram
location_id: stock.stock_location_stock
location_dest_id: stock.stock_location_customers
product_qty: 500.0
type: out
picking_type_id: stock.picking_type_out
-
I assign this outgoing shipment
-
@ -144,11 +132,11 @@
-
Process the delivery of the outgoing shipment
-
!python {model: stock.partial.picking}: |
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_uom")], 'default_type':'out'})
self.do_partial(cr, uid, [partial_id])
!python {model: stock.picking}: |
pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_uom"))
pick_obj.do_partial(context=context)
-
Check product price changed to 80.0
Check product price changed to 80.0 (because last outgoing shipment was made of 0.5 kg at 80€)
-
!python {model: product.product}: |
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 80.0
@ -201,15 +189,14 @@
-
Process the reception of purchase order with usd
-
!python {model: stock.partial.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_usd")).picking_ids
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
self.do_partial(cr, uid, [partial_id])
!python {model: stock.picking}: |
pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("purchase_order_fifo_usd"))
pick_obj.do_partial(context=context)
-
We create delivery order of 49.5 kg
-
!record {model: stock.picking, id: outgoing_fifo_shipment_cur}:
type: out
picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@ -218,7 +205,9 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 49.5
type: out
location_id: stock.stock_location_stock
location_dest_id: stock.stock_location_customers
picking_type_id: stock.picking_type_out
-
I assign this outgoing shipment
-
@ -227,11 +216,11 @@
-
Process the delivery of the outgoing shipment
-
!python {model: stock.partial.picking}: |
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_cur")], 'default_type':'out'})
self.do_partial(cr, uid, [partial_id])
!python {model: stock.picking}: |
picking_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_cur"))
picking_obj.do_partial(context=context)
-
Check rounded price is 102 euro
Check rounded price is 102 euro (because last outgoing shipment was made of 19.5kg at 80€ and 30kg at $150 (rate=1.2834)
-
!python {model: product.product}: |
assert round(self.browse(cr, uid, ref("product_fifo_icecream")).standard_price) == 102, "Price after doing other currency is wrong"
@ -239,7 +228,7 @@
Do a delivery of an extra 10 kg
-
!record {model: stock.picking, id: outgoing_fifo_shipment_ret}:
type: out
picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@ -248,7 +237,9 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 10.0
type: out
location_id: stock.stock_location_stock
location_dest_id: stock.stock_location_customers
picking_type_id: stock.picking_type_out
-
I assign this outgoing shipment
-
@ -257,9 +248,9 @@
-
Process the delivery of the outgoing shipment
-
!python {model: stock.partial.picking}: |
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_ret")], 'default_type':'out'})
self.do_partial(cr, uid, [partial_id])
!python {model: stock.picking}: |
picking_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_ret"))
picking_obj.do_partial(context=context)
-
Check rounded price is 150.0 / 1.2834
-
@ -269,7 +260,7 @@
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}:
type: out
picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@ -278,12 +269,14 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 200.0
type: out
location_id: stock.stock_location_stock
location_dest_id: stock.stock_location_customers
picking_type_id: stock.picking_type_out
-
Let us create another out of 400 kg, but will pick only 50 kg
-
!record {model: stock.picking, id: outgoing_fifo_shipment_neg2}:
type: out
picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@ -292,19 +285,17 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 400.0
type: out
location_id: stock.stock_location_stock
location_dest_id: stock.stock_location_customers
picking_type_id: stock.picking_type_out
-
Process the delivery of the outgoing shipments
-
!python {model: stock.partial.picking}: |
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_neg")], 'default_type':'out'})
line = self.browse(cr, uid, partial_id, context=context).move_ids[0]
self.pool.get("stock.partial.picking.line").write(cr, uid, [line.id], {'quantity':100})
self.do_partial(cr, uid, [partial_id])
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_neg2")], 'default_type':'out'})
line = self.browse(cr, uid, partial_id, context=context).move_ids[0]
self.pool.get("stock.partial.picking.line").write(cr, uid, [line.id], {'quantity':50})
self.do_partial(cr, uid, [partial_id])
!python {model: stock.picking}: |
picking_obj = self.browse(cr, uid, ref("outgoing_fifo_shipment_neg"))
picking_obj.do_partial(context=context)
picking_obj1 = self.browse(cr, uid, ref("outgoing_fifo_shipment_neg2"))
picking_obj1.do_partial(context=context)
-
Receive purchase order with 50 kg FIFO Ice Cream at 50 euro/kg
-
@ -325,10 +316,9 @@
-
Process the reception of purchase order 1
-
!python {model: stock.partial.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_neg")).picking_ids
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
self.do_partial(cr, uid, [partial_id])
!python {model: stock.picking}: |
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_neg")).picking_ids[0]
picking_obj.do_partial(context=context)
-
Assert price on product is still the old price as the out move has not been received fully yet
-
@ -354,12 +344,11 @@
-
Process the reception of purchase order 2
-
!python {model: stock.partial.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_neg2")).picking_ids
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
self.do_partial(cr, uid, [partial_id])
!python {model: stock.picking}: |
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_neg2")).picking_ids[0]
picking_obj.do_partial(context=context)
-
The price of the product should have changed back to 65.0
-
!python {model: product.product}: |
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 65.0
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 65.0