2 Set product category removal strategy as LIFO
4 !record {model: product.category, id: product.product_category_001}:
6 removal_strategy_id: stock.removal_lifo
8 Set a product as using lifo price
10 !record {model: product.product, id: product_lifo_icecream}:
14 categ_id: product.product_category_001
17 uom_id: product.product_uom_kgm
18 uom_po_id: product.product_uom_kgm
21 property_stock_account_input: account.o_expense
22 property_stock_account_output: account.o_income
23 description: LIFO 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.
25 I create a draft Purchase Order for first in move for 10 pieces at 60 euro
27 !record {model: purchase.order, id: purchase_order_lifo1}:
28 partner_id: base.res_partner_3
29 location_id: stock.stock_location_stock
30 pricelist_id: purchase.list0
32 - product_id: product_lifo_icecream
34 product_uom: product.product_uom_kgm
36 name: 'LIFO Ice Cream'
38 I create a draft Purchase Order for second shipment for 30 pieces at 80 euro
40 !record {model: purchase.order, id: purchase_order_lifo2}:
41 partner_id: base.res_partner_3
42 location_id: stock.stock_location_stock
43 pricelist_id: purchase.list0
45 - product_id: product_lifo_icecream
47 product_uom: product.product_uom_kgm
49 name: 'LIFO Ice Cream'
51 I confirm the first purchase order
53 !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_lifo1}
55 I check the "Approved" status of purchase order 1
57 !assert {model: purchase.order, id: purchase_order_lifo1}:
60 Process the receipt of purchase order 1
62 !python {model: stock.picking}: |
63 order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo1"), context=context).picking_ids[0]
66 Check the standard price of the product (lifo icecream)
68 !python {model: product.product}: |
69 assert self.browse(cr, uid, ref("product_lifo_icecream")).standard_price == 70.0, 'Standard price should not have changed!'
71 I confirm the second purchase order
73 !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_lifo2}
75 Process the receipt of purchase order 2
77 !python {model: stock.picking}: |
78 order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo2"), context=context).picking_ids[0]
81 Check the standard price should not have changed
83 !python {model: product.product}: |
84 assert self.browse(cr, uid, ref("product_lifo_icecream")).standard_price == 70.0, 'Standard price as lifo price of second receipt incorrect!'
86 Let us send some goods
88 !record {model: stock.picking, id: outgoing_lifo_shipment}:
89 picking_type_id: stock.picking_type_out
91 Picking needs movement from stock
93 !record {model: stock.move, id: outgoing_shipment_lifo_icecream}:
94 picking_id: outgoing_lifo_shipment
95 product_id: product_lifo_icecream
96 product_uom: product.product_uom_kgm
97 location_id: stock.stock_location_stock
98 location_dest_id: stock.stock_location_customers
100 picking_type_id: stock.picking_type_out
102 I assign this outgoing shipment
104 !python {model: stock.picking}: |
105 self.action_assign(cr, uid, [ref("outgoing_lifo_shipment")])
107 Process the delivery of the outgoing shipment
109 !python {model: stock.picking}: |
110 pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_lifo_shipment"), context=context)
111 pick_order.do_transfer()
113 Check standard price became 80 euro
115 !python {model: product.product}: |
116 assert self.browse(cr, uid, ref("product_lifo_icecream")).standard_price == 80.0, 'Price should have been 80 euro'