Tryton - Issues

 

Issue9443

Title Keep last cost price when quantity is zero
Priority bug Status resolved
Superseder Nosy List bernatnan, ced, pokoli, reviewbot, roundup-bot
Type behavior Components product_cost_fifo
Assigned To ced Keywords review
Reviews 317771007
View: 317771007

Created on 2020-06-25.17:05:20 by ced, last changed by roundup-bot.

Messages
New changeset 5033ef9f2352 by Cédric Krier in branch 'default':
Keep last cost price when quantity is zero
https://hg.tryton.org/tryton-env/rev/5033ef9f2352
New changeset d22c29f6a03d by Cédric Krier in branch 'default':
Keep last cost price when quantity is zero
https://hg.tryton.org/modules/product_cost_fifo/rev/d22c29f6a03d
msg58928 (view) Author: [hidden] (bernatnan) Date: 2020-07-01.22:56:16
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.
msg58923 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2020-07-01.12:31:40
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).
msg58922 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2020-07-01.10:20:05
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.
msg58921 (view) Author: [hidden] (bernatnan) Date: 2020-07-01.02:07:24
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. :-)
msg58916 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2020-06-30.22:05:33
I think using the last cost price is more accurate than using 0.
msg58915 (view) Author: [hidden] (bernatnan) Date: 2020-06-30.19:13:58
Sorry, that's not what I'm trying to explain on the comment that trigger this issue (from https://codereview.tryton.org/327491003/diff/315661002/modules/stock/move.py?context=10&column_width=80). I suppose that I haven't explained well.

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:
review317771007 updated at https://codereview.tryton.org/317771007/#ps295821003
msg58877 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2020-06-25.17:05:19
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
History
Date User Action Args
2020-07-13 20:48:59roundup-botsetmessages: + msg59294
2020-07-13 20:48:46roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg59293
2020-07-01 22:56:16bernatnansetmessages: + msg58928
2020-07-01 12:31:40pokolisetnosy: + pokoli
messages: + msg58923
2020-07-01 10:20:05cedsetmessages: + msg58922
2020-07-01 02:07:25bernatnansetmessages: + msg58921
2020-06-30 22:05:33cedsetmessages: + msg58916
2020-06-30 19:13:59bernatnansetnosy: + bernatnan
messages: + msg58915
2020-06-25 17:29:27reviewbotsetnosy: + reviewbot
messages: + msg58879
2020-06-25 17:07:00cedsetstatus: in-progress -> testing
reviews: 317771007
keyword: + review

Showing 10 items. Show all history (warning: this could be VERY long)