[IMP] Maifest for Github README.md on main apps
[odoo/odoo.git] / addons / stock_dropshipping / test / lifo_price.yml
1
2   Set product category removal strategy as LIFO 
3
4   !record {model: product.category, id: product.product_category_001}:
5     name : Lifo Category
6     removal_strategy_id: stock.removal_lifo
7 -
8   Set a product as using lifo price
9 -
10   !record {model: product.product, id: product_lifo_icecream}:
11     default_code: LIFO
12     name: LIFO Ice Cream
13     type: product
14     categ_id: product.product_category_001
15     list_price: 100.0
16     standard_price: 70.0
17     uom_id: product.product_uom_kgm
18     uom_po_id: product.product_uom_kgm
19     valuation: real_time
20     cost_method: real
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.
24
25   I create a draft Purchase Order for first in move for 10 pieces at 60 euro
26
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
31     order_line:
32       - product_id: product_lifo_icecream
33         product_qty: 10.0
34         product_uom: product.product_uom_kgm
35         price_unit: 60.0
36         name: 'LIFO Ice Cream'
37
38   I create a draft Purchase Order for second shipment for 30 pieces at 80 euro
39
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
44     order_line:
45       - product_id: product_lifo_icecream
46         product_qty: 30.0
47         product_uom: product.product_uom_kgm
48         price_unit: 80.0
49         name: 'LIFO Ice Cream'
50
51   I confirm the first purchase order
52 -
53   !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_lifo1}
54 -
55   I check the "Approved" status of purchase order 1
56 -
57   !assert {model: purchase.order, id: purchase_order_lifo1}:
58     - state == 'approved'
59
60   Process the receipt of purchase order 1
61 -
62   !python {model: stock.picking}: |
63     order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo1"), context=context).picking_ids[0]
64     order.do_transfer()
65
66   Check the standard price of the product (lifo icecream)
67
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!'
70
71   I confirm the second purchase order
72
73   !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_lifo2}
74 -
75   Process the receipt of purchase order 2
76
77   !python {model: stock.picking}: |
78     order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo2"), context=context).picking_ids[0]
79     order.do_transfer()
80
81   Check the standard price should not have changed
82
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!'
85
86   Let us send some goods
87
88   !record {model: stock.picking, id: outgoing_lifo_shipment}:
89     picking_type_id: stock.picking_type_out
90 -
91   Picking needs movement from stock
92 -
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
99     product_uom_qty: 20.0
100     picking_type_id: stock.picking_type_out
101
102   I assign this outgoing shipment 
103
104   !python {model: stock.picking}: |
105     self.action_assign(cr, uid, [ref("outgoing_lifo_shipment")])
106
107   Process the delivery of the outgoing shipment
108
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()
112 -
113   Check standard price became 80 euro
114 -
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'