[REF] stock_account: support valuation at date
For the standard and average cost method, we use `qty_available` at date and the `product.price.history` table. For FIFO, the normal way would have been to get the `qty_available` at date and value this quantity with the more recent IN moves at this date. But there's two main obstacles preventing to use this solution: - when editing a done move to change the quantity, the change is reflected at the date, the `qty_available` at date will be incremented - in the same usecase, the remaining_qty and remaining_value is incremented in place, which mean that even if the layer was already consumed, it's now appearing again at the bottom of the fifo layer Fixing this issue by adding a stock move at the date of today instead of editing in place in v11 and adding a proper "cost layer" model in master was deemed too complex as well as unnecessary by our bosses So we now say we continue to update in place, and when looking at the quantity at date - if periodic, we sum the value of the move since the beginning of times - if perpetual, we sum the balance of the account move lines since the beginning of times. Also, in this case, the quantity at date is computed across account move lines too, via the "quantity" field on aml. This commit adds three non stored computed field: - qty_at_date: will be computed across stock moves if fifo periodic and across account move line if fifo perpetual to reflect the design choice: if periodic, we *really* edit in the past ; if perpetual, no, the change is done at today's date - stock_fifo_real_time_aml_ids: the used aml to compute qty_at_date - stock_fifo_manual_move_ids: the used move to compute qty_at_date
This diff is collapsed.
Please register or sign in to comment