Since rev f3fcb65989bf, we recompute the cost price on moves but when the quantity stored in zero, we set the "average" cost price to zero.
But this is not the same behavior as when move is done where we keep last cost price (from Move._compute_product_cost_price).
This was pointed in https://codereview.tryton.org/327491003/diff/315661002/modules/stock/move.py#newcode498
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
...
Linked items
0
Link issues together to show that they're related.
Learn more.
The problem is that when you make a sale with all the remaining stock that you have, when "do" de move and the product stock become 0, the price not become 0€, it's remain like the cost_price of the move. So the problem is not in the "recompute_cost_price_fifo" function, it's in the move.py, and for me the solutions will be in the "_compute_product_cost_price" function, that it's in "stock" module, move.py file:
Replacing the 498 line for:
if product_qty + qty == 0:
new_cost_price = Decimal(0)
elif product_qty + qty > 0 and product_qty >= 0:
But if you don't have stock, the cost of this product in this moment it's 0€, it's not the last cost.
If you need to know your warehouse stock in money, is strange that you put a cost a product that you don't have. I know that will multiply by 0 units, but is strange.
On 2020-07-01 02:07, Bernat Brunet wrote:
> But if you don't have stock, the cost of this product in this moment it's 0€, it's not the last cost.
> If you need to know your warehouse stock in money, is strange that you put a cost a product that you don't have. I know that will multiply by 0 units, but is strange.
>
> No stock, no cost. :-)
Do not confuse the stock cost and the product cost price. A product can
have a cost price even if there is no quantity in stock.
For me, keeping the last cost price is the best approximation for the
future cost price. And it is especially good if a product is returned or
if you find product thanks to inventory.
I agree with cedric here. I prefer to have the last value as cost price.
Once you have zero as quantity the cost_value of the product in your warehouse will always be zero (as the quantity is zero).
I know the difference between stock cost and product cost price and that with stock 0 the cost_value of the product will be 0€. I only say that when you look the product list with 0 stock and see cost_price on it is strange.
But it's ok that appear the last cost_price, I talk with Albert and Àngel and they think that's ok.