Comment 4 for bug 779145

Revision history for this message
Ferdinand (office-chricar) wrote : Re: stock move - price_unit missing for avg price and not "IN"

let's start with a bit of accounting theory

product value = qty*price

simplest case: product_values in all of these records are identical
* PO/SO line == stock_move == invoice_line == account_move

if AVERAGE and REAL TIME price is used in a volatile market the product average price will change with every incoming product move.

to be able to calculate correctly the value of a product at period (month/year) end we MUST store the product value (or it's components qty and price) in every stock move.

this is also necessary to make stock reports and analysis - which must include values - returning meaningful values.

currently only the price of incoming goods is stored - IMHO the "current" price for all moves must be stored to be able to generate reproducable results.

product_product.standard_price * product_product.qty_available gives "only" the correct value for all other point in time it is WRONG!.

the patch adds the current "price_unit" to each stock move which allows to calculate
* stock value = sum(price_unit*qty) for every point in time.

I suggest to store move_value = price_unit * qty for every stock move.
* stock_value = sum(move_value) to avoid rounding differences and differences to account_move_lines.

in "Moves Analysis" there is a column "Total Value" and IMHO this must show correct figures
similar in "Inventory Analysis" grouped by "Date"

in
./report/report_stock_move.py
                        CASE WHEN sp.type in ('in') THEN
                            sum(sm.product_qty * pu.factor) * pt.standard_price
                            ELSE 0.0
                            END AS in_value,

returns wrong and unsusable values .....
it is absulutely necessary to use the price_unit of the move line.

and instead of haveing to calcualte
- sum(sm.product_qty * pu.factor) * move.price_unit
we should have
- sum(move_value)

BTW much if this is available in
http://bazaar.launchpad.net/~c2c/+junk/c2c_austria_dev/files/head:/c2c_stock_accounting/

we really should team up to get a working stock accounting ASAP.