2013-04-26 11:17:30 +00:00
-
Set a product as using fifo price
-
!record {model: product.product, id: product_fifo_icecream}:
default_code : FIFO
name : FIFO Ice Cream
type : product
categ_id : product.product_category_1
list_price : 100.0
standard_price : 70.0
uom_id : product.product_uom_kgm
uom_po_id : product.product_uom_kgm
2013-06-25 15:26:20 +00:00
cost_method : real
2013-05-03 09:56:35 +00:00
valuation : real_time
2013-04-26 11:17:30 +00:00
property_stock_account_input : account.o_expense
property_stock_account_output : account.o_income
description : FIFO Ice Cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events.
-
2013-05-25 13:16:39 +00:00
I create a draft Purchase Order for first in move for 10 kg at 50 euro
2013-04-26 11:17:30 +00:00
-
!record {model: purchase.order, id: purchase_order_fifo1}:
partner_id : base.res_partner_3
location_id : stock.stock_location_stock
pricelist_id : 1
order_line :
- product_id : product_fifo_icecream
product_qty : 10.0
2013-11-28 13:33:02 +00:00
product_uom : product.product_uom_kgm
2013-04-29 10:39:14 +00:00
price_unit : 50.0
2013-04-26 11:17:30 +00:00
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'
-
2013-05-25 13:16:39 +00:00
Process the reception of purchase order 1 and set date
2013-04-26 11:17:30 +00:00
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo1"), context=context).picking_ids[0]
picking_obj.do_transfer()
2013-04-26 11:17:30 +00:00
-
2013-09-03 08:19:24 +00:00
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
2013-04-26 11:17:30 +00:00
-
!python {model: product.product}: |
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 70.0, 'Standard price should not have changed!'
2013-05-10 09:50:05 +00:00
-
2013-09-03 08:19:24 +00:00
I create a draft Purchase Order for second shipment for 30 kg at 80 euro
2013-05-07 14:04:43 +00:00
-
2013-09-03 08:19:24 +00:00
!record {model: purchase.order, id: purchase_order_fifo2}:
2013-05-07 14:04:43 +00:00
partner_id : base.res_partner_3
2013-09-03 08:19:24 +00:00
location_id : stock.stock_location_stock
2013-05-07 14:04:43 +00:00
pricelist_id : 1
order_line :
- product_id : product_fifo_icecream
2013-09-03 08:19:24 +00:00
product_qty : 30.0
2013-11-28 13:33:02 +00:00
product_uom : product.product_uom_kgm
2013-09-03 08:19:24 +00:00
price_unit : 80.0
2013-05-07 14:04:43 +00:00
name : 'FIFO Ice Cream'
2013-04-26 11:17:30 +00:00
-
2013-05-10 09:50:05 +00:00
I confirm the second purchase order
-
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_fifo2}
2013-04-26 11:17:30 +00:00
-
Process the reception of purchase order 2
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo2"), context=context).picking_ids[0]
picking_obj.do_transfer()
2013-05-07 14:04:43 +00:00
-
2013-09-03 08:19:24 +00:00
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
2013-04-26 11:17:30 +00:00
-
!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!'
-
Let us send some goods
-
!record {model: stock.picking, id: outgoing_fifo_shipment}:
2013-08-29 12:30:42 +00:00
picking_type_id : stock.picking_type_out
2013-04-26 11:17:30 +00:00
-
Picking needs movement from stock
-
!record {model: stock.move, id: outgoing_shipment_fifo_icecream}:
picking_id : outgoing_fifo_shipment
product_id : product_fifo_icecream
product_uom : product.product_uom_kgm
2013-09-03 16:27:57 +00:00
product_uom_qty : 20.0
2013-08-29 12:30:42 +00:00
location_id : stock.stock_location_stock
location_dest_id : stock.stock_location_customers
picking_type_id : stock.picking_type_out
2013-06-20 16:41:06 +00:00
-
I assign this outgoing shipment
-
!python {model: stock.picking}: |
2013-06-29 20:53:24 +00:00
self.action_assign(cr, uid, [ref("outgoing_fifo_shipment")])
2013-04-26 11:17:30 +00:00
-
Process the delivery of the outgoing shipment
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment"), context=context)
pick_obj.do_transfer()
2013-04-29 10:39:14 +00:00
-
2013-09-03 08:19:24 +00:00
Check product standard price changed to 65.0 (because last outgoing shipment was made of 10 kg at 50€ and 10 kg at 80€)
2013-04-29 10:39:14 +00:00
-
!python {model: product.product}: |
2013-09-03 16:27:57 +00:00
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 65.0, "Product price not updated accordingly. %s found instead of 65" %(self.browse(cr, uid, ref("product_fifo_icecream")).standard_price,)
2013-04-29 10:39:14 +00:00
-
Do a delivery of an extra 500 g (delivery order)
-
2013-04-30 09:13:45 +00:00
!record {model: stock.picking, id: outgoing_fifo_shipment_uom}:
2013-08-29 12:30:42 +00:00
picking_type_id : stock.picking_type_out
2013-04-29 10:39:14 +00:00
-
Picking needs movement from stock
-
!record {model: stock.move, id: outgoing_shipment_fifo_icecream_gram}:
2013-04-30 09:13:45 +00:00
picking_id : outgoing_fifo_shipment_uom
2013-04-29 10:39:14 +00:00
product_id : product_fifo_icecream
product_uom : product.product_uom_gram
2013-08-29 12:30:42 +00:00
location_id : stock.stock_location_stock
location_dest_id : stock.stock_location_customers
2013-09-03 16:27:57 +00:00
product_uom_qty : 500.0
2013-08-29 12:30:42 +00:00
picking_type_id : stock.picking_type_out
2013-04-29 10:39:14 +00:00
-
2013-06-20 16:41:06 +00:00
I assign this outgoing shipment
-
!python {model: stock.picking}: |
2013-06-29 20:53:24 +00:00
self.action_assign(cr, uid, [ref("outgoing_fifo_shipment_uom")])
2013-06-20 16:41:06 +00:00
-
2013-04-29 10:39:14 +00:00
Process the delivery of the outgoing shipment
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_uom"), context=context)
pick_obj.do_transfer()
2013-04-29 10:39:14 +00:00
-
2013-09-03 08:19:24 +00:00
Check product price changed to 80.0 (because last outgoing shipment was made of 0.5 kg at 80€)
2013-04-29 10:39:14 +00:00
-
!python {model: product.product}: |
2013-09-03 16:27:57 +00:00
assert self.browse(cr, uid, ref("product_fifo_icecream")).standard_price == 80.0, "Product price not updated accordingly. %s found instead of 80" %(self.browse(cr, uid, ref("product_fifo_icecream")).standard_price,)
2013-06-07 08:29:03 +00:00
-
We will temporarily change the currency rate on the sixth of June to have the same results all year
-
!record {model: res.currency.rate, id: base.rateUSDbis}:
rate : 1.2834
currency_id : base.USD
name : !eval time.strftime('%Y-06-06')
2013-05-03 09:56:35 +00:00
-
Create new pricelist in usd
-
!record {model: product.pricelist, id: supplier_pricelist_usd}:
name : Supplier Pricelist
type : purchase
currency_id : base.USD
version_id :
- name : v1.0
items_id :
2013-05-15 12:44:57 +00:00
- name : First version
2013-05-03 09:56:35 +00:00
sequence : 1
price_min_margin : 2
price_max_margin : 5
product_id : product_fifo_icecream
base : -2
-
Purchase order in usd
-
2013-06-03 15:15:21 +00:00
I create a draft Purchase Order for 30000 g at 0.150 USD/g and 10 kg at 150 USD/kg
2013-05-03 09:56:35 +00:00
-
!record {model: purchase.order, id: purchase_order_fifo_usd}:
partner_id : base.res_partner_3
location_id : stock.stock_location_stock
2013-05-15 12:44:57 +00:00
pricelist_id : supplier_pricelist_usd
2013-05-03 09:56:35 +00:00
order_line :
- product_id : product_fifo_icecream
2013-06-03 15:15:21 +00:00
product_qty : 30000
product_uom : product.product_uom_gram
price_unit : 0.150
2013-05-03 09:56:35 +00:00
name : 'FIFO Ice Cream'
2013-05-03 13:32:05 +00:00
- product_id : product_fifo_icecream
product_qty : 10.0
product_uom : product.product_uom_kgm
2013-05-15 12:44:57 +00:00
price_unit : 150.0
2013-05-03 09:56:35 +00:00
-
2013-05-10 13:17:32 +00:00
I confirm the purchase order in USD
2013-05-03 09:56:35 +00:00
-
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_fifo_usd}
-
Process the reception of purchase order with usd
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
pick_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_usd"), context=context).picking_ids[0]
pick_obj.do_transfer()
2013-05-03 09:56:35 +00:00
-
2013-06-03 15:15:21 +00:00
We create delivery order of 49.5 kg
2013-05-03 09:56:35 +00:00
-
!record {model: stock.picking, id: outgoing_fifo_shipment_cur}:
2013-08-29 12:30:42 +00:00
picking_type_id : stock.picking_type_out
2013-05-03 09:56:35 +00:00
-
Picking needs movement from stock
-
!record {model: stock.move, id: outgoing_shipment_fifo_icecream_cur}:
picking_id : outgoing_fifo_shipment_cur
product_id : product_fifo_icecream
2013-05-25 13:16:39 +00:00
product_uom : product.product_uom_kgm
2013-09-03 16:27:57 +00:00
product_uom_qty : 49.5
2013-08-29 12:30:42 +00:00
location_id : stock.stock_location_stock
location_dest_id : stock.stock_location_customers
picking_type_id : stock.picking_type_out
2013-06-20 16:41:06 +00:00
-
I assign this outgoing shipment
-
!python {model: stock.picking}: |
2013-06-29 20:53:24 +00:00
self.action_assign(cr, uid, [ref("outgoing_fifo_shipment_cur")])
2013-05-03 09:56:35 +00:00
-
Process the delivery of the outgoing shipment
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
picking_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_cur"), context=context)
picking_obj.do_transfer()
2013-05-03 13:32:05 +00:00
-
2013-09-03 08:19:24 +00:00
Check rounded price is 102 euro (because last outgoing shipment was made of 19.5kg at 80€ and 30kg at $150 (rate=1.2834)
2013-05-03 13:32:05 +00:00
-
2013-06-20 16:41:06 +00:00
!python {model: product.product}: |
2013-09-03 16:27:57 +00:00
assert round(self.browse(cr, uid, ref("product_fifo_icecream")).standard_price) == 102, "Product price not updated accordingly. %s found instead of 102 (rounded values)" %(round(self.browse(cr, uid, ref("product_fifo_icecream")).standard_price),)
2013-05-03 13:32:05 +00:00
-
2013-05-25 13:16:39 +00:00
Do a delivery of an extra 10 kg
2013-05-03 13:32:05 +00:00
-
2013-05-23 18:52:32 +00:00
!record {model: stock.picking, id: outgoing_fifo_shipment_ret}:
2013-08-29 12:30:42 +00:00
picking_type_id : stock.picking_type_out
2013-05-23 18:52:32 +00:00
-
Picking needs movement from stock
-
!record {model: stock.move, id: outgoing_shipment_fifo_icecream_ret}:
picking_id : outgoing_fifo_shipment_ret
product_id : product_fifo_icecream
product_uom : product.product_uom_kgm
2013-09-03 16:27:57 +00:00
product_uom_qty : 10.0
2013-08-29 12:30:42 +00:00
location_id : stock.stock_location_stock
location_dest_id : stock.stock_location_customers
picking_type_id : stock.picking_type_out
2013-06-20 16:41:06 +00:00
-
I assign this outgoing shipment
-
!python {model: stock.picking}: |
2013-06-29 20:53:24 +00:00
self.action_assign(cr, uid, [ref("outgoing_fifo_shipment_ret")])
2013-05-23 18:52:32 +00:00
-
Process the delivery of the outgoing shipment
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
picking_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_ret"), context=context)
picking_obj.do_transfer()
2013-05-03 13:32:05 +00:00
-
Check rounded price is 150.0 / 1.2834
-
!python {model: product.product}: |
2013-09-09 10:02:29 +00:00
product = self.browse(cr, uid, ref("product_fifo_icecream"))
assert round(product.standard_price) == round(150.0 / 1.2834), "Product price not updated accordingly. %s found instead of %s" %(product.standard_price, round(150.0/1.2834))
assert product.qty_available == 0.0, 'Wrong quantity in stock after first reception'
2013-05-17 15:50:04 +00:00
-
2013-09-17 10:29:32 +00:00
Let us create some outs to get negative stock for a new product using the same config
-
!record {model: product.product, id: product_fifo_negative}:
default_code : NEG
name : FIFO Negative
type : product
categ_id : product.product_category_1
list_price : 100.0
standard_price : 70.0
uom_id : product.product_uom_kgm
uom_po_id : product.product_uom_kgm
cost_method : real
valuation : real_time
property_stock_account_input : account.o_expense
property_stock_account_output : account.o_income
description :
-
Create outpicking. We create delivery order of 100 kg.
2013-05-17 15:50:04 +00:00
-
!record {model: stock.picking, id: outgoing_fifo_shipment_neg}:
2013-08-29 12:30:42 +00:00
picking_type_id : stock.picking_type_out
2013-05-17 15:50:04 +00:00
-
Picking needs movement from stock
-
!record {model: stock.move, id: outgoing_shipment_fifo_icecream_neg}:
picking_id : outgoing_fifo_shipment_neg
2013-09-17 10:29:32 +00:00
product_id : product_fifo_negative
2013-05-17 15:50:04 +00:00
product_uom : product.product_uom_kgm
2013-09-09 10:02:29 +00:00
product_uom_qty : 100.0
2013-08-29 12:30:42 +00:00
location_id : stock.stock_location_stock
location_dest_id : stock.stock_location_customers
picking_type_id : stock.picking_type_out
2013-05-17 15:50:04 +00:00
-
2013-09-09 10:02:29 +00:00
Process the delivery of the first outgoing shipment
-
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
picking_obj = self.browse(cr, uid, ref("outgoing_fifo_shipment_neg"), context=context)
picking_obj.do_transfer()
2013-09-18 13:27:18 +00:00
-
The behavior of fifo/lifo is not garantee if the quants are created at the same second, so i just wait one second
-
2013-09-18 14:24:57 +00:00
!python {model: stock.picking}: |
2013-09-18 13:27:18 +00:00
import time
time.sleep(1)
2013-09-09 10:02:29 +00:00
-
Let us create another out of 400 kg
2013-05-17 15:50:04 +00:00
-
!record {model: stock.picking, id: outgoing_fifo_shipment_neg2}:
2013-08-29 12:30:42 +00:00
picking_type_id : stock.picking_type_out
2013-05-17 15:50:04 +00:00
-
Picking needs movement from stock
-
!record {model: stock.move, id: outgoing_shipment_fifo_icecream_neg2}:
picking_id : outgoing_fifo_shipment_neg2
2013-09-17 10:29:32 +00:00
product_id : product_fifo_negative
2013-05-17 15:50:04 +00:00
product_uom : product.product_uom_kgm
2013-09-03 16:27:57 +00:00
product_uom_qty : 400.0
2013-08-29 12:30:42 +00:00
location_id : stock.stock_location_stock
location_dest_id : stock.stock_location_customers
picking_type_id : stock.picking_type_out
2013-05-17 15:50:04 +00:00
-
Process the delivery of the outgoing shipments
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
picking_obj1 = self.browse(cr, uid, ref("outgoing_fifo_shipment_neg2"), context=context)
picking_obj1.do_transfer()
2013-09-24 14:32:20 +00:00
2013-05-17 15:50:04 +00:00
-
2013-05-25 13:16:39 +00:00
Receive purchase order with 50 kg FIFO Ice Cream at 50 euro/kg
2013-05-17 15:50:04 +00:00
-
!record {model: purchase.order, id: purchase_order_fifo_neg}:
partner_id : base.res_partner_3
location_id : stock.stock_location_stock
pricelist_id : 1
order_line :
2013-09-17 10:29:32 +00:00
- product_id : product_fifo_negative
2013-05-25 13:16:39 +00:00
product_qty : 50.0
2013-11-28 13:33:02 +00:00
product_uom : product.product_uom_kgm
2013-05-17 15:50:04 +00:00
price_unit : 50.0
name : 'FIFO Ice Cream'
-
I confirm the first purchase order
-
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_fifo_neg}
-
Process the reception of purchase order 1
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_neg"), context=context).picking_ids[0]
picking_obj.do_transfer()
2013-05-21 17:26:27 +00:00
-
2013-05-25 13:16:39 +00:00
Assert price on product is still the old price as the out move has not been received fully yet
2013-05-21 17:26:27 +00:00
-
!python {model: product.product}: |
2013-09-24 14:32:20 +00:00
2013-09-17 11:48:53 +00:00
assert self.browse(cr, uid, ref("product_fifo_negative")).standard_price == 70, 'The product price should not have been updated'
2013-05-21 17:26:27 +00:00
-
2013-05-25 13:16:39 +00:00
Receive purchase order with 60 kg FIFO Ice Cream at 80 euro/kg
2013-05-21 17:26:27 +00:00
-
!record {model: purchase.order, id: purchase_order_fifo_neg2}:
partner_id : base.res_partner_3
location_id : stock.stock_location_stock
pricelist_id : 1
order_line :
2013-09-17 10:29:32 +00:00
- product_id : product_fifo_negative
2013-05-25 13:16:39 +00:00
product_qty : 60.0
2013-11-28 13:33:02 +00:00
product_uom : product.product_uom_kgm
2013-05-21 17:26:27 +00:00
price_unit : 80
name : 'FIFO Ice Cream'
-
I confirm the second negative purchase order
2013-09-17 12:46:48 +00:00
-
2013-05-21 17:26:27 +00:00
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_fifo_neg2}
-
Process the reception of purchase order 2
2013-09-17 12:46:48 +00:00
-
2013-08-29 12:30:42 +00:00
!python {model: stock.picking}: |
2014-07-06 14:44:26 +00:00
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_neg2"), context=context).picking_ids[0]
picking_obj.do_transfer()
2013-05-17 15:50:04 +00:00
-
2013-05-25 13:16:39 +00:00
The price of the product should have changed back to 65.0
2013-05-03 09:56:35 +00:00
-
!python {model: product.product}: |
2013-09-18 13:27:18 +00:00
assert self.browse(cr, uid, ref("product_fifo_negative")).standard_price == 65.0, "Product price not updated accordingly. %s found instead of 65" %(self.browse(cr, uid, ref("product_fifo_negative")).standard_price,)