[IMP] Remove prints, add docs, refactor variables in price_calculation, uom_compute...
[odoo/odoo.git] / addons / purchase / doc / fifolifo.rst
1 FIFO/LIFO
2
3 In order to activate FIFO/LIFO, the costing method in the product form should be fifo/lifo.  This is only possible when cost methods are checked under Settings > Purchase
4
5
6
7 Normal case:
8 ------------
9
10 = When product is purchased by purchase order and leaves towards a customer with a delivery order.  We assume also 
11 that accounting entries are generated in real-time.  
12
13 - When product is received, the stock move gets the unit price and UoM of the purchase order
14 - In the stock journal, the accounting items will be generated based on this.  
15 - When a delivery order is made, the FIFO/LIFO algorithm is used to check which in moves correspond to this out move.  A weighted average is calculated 
16 based on the different in moves which would theoretically have gone out according to the FIFO/LIFO algorithm.  This average becomes also the new cost price on the product.  
17 Technically, these calculated matchings are saved in stock_move_matching which makes further FIFO/LIFO calculations easier.  
18 - When generating accounting entries, the stock.move.matching table is used, to generate 1 account move line per matching.  That way, one stock move will have one account 
19 move with multiple account move lines with the amounts from the matchings.   
20
21
22 Case of production: 
23 -------------------
24 In case of produced goods, the incoming stock move of the finished product and accounting entries can not just invent a cost price like the sum of the cost price of the parts in the BoM, as costing methods tend to be a lot more complicated than this. 
25 On the stock move, we will put the cost price of the product.  
26
27 Case of no purchase order
28 -------------------------
29 When no purchase order is given, the price on the stock move and generated entries is the standard price on the product.  
30
31
32 Returned Goods / Scrap / ...
33 ----------------------------
34 Returned goods to supplier have the same calculations as a normal out, same with scrap.  
35
36
37 Negative stocks
38 ---------------
39 When an out move makes the stock (quantity on hand) become negative, the cost price of the product is not updated and stock move matchings will only be created for the moves that can be matched.  (until stock is zero)  If the quantity on hand became negative and afterwards we get an incoming move, the system will try to match the previous outgoing move(s) as much as possible with the incoming move.  These matches will generate also the necessary accounting entries.  
40
41
42 Inter-company
43 -------------
44 cost price, costing method and valuation (real_time or manual_periodic) are properties (are different according to the company) => when you receive/ship goods, it depends on the company of the stock move as what costing method needs to be used. 
45
46 Not possible to create a stock move between two locations of different companies.  You need a transit location in between.  This new constraint removes the requirement for a currency or two prices on one stock move.  
47
48 UoMs: As quantities need to be matched between outgoing and ingoing stock moves which can have different UoMs, it will take all these conversions into account
49
50 Currency: On the stock move, the currency is the company currency