erp5_core: fix FIFO stock value calculation on null total price
When creating two simulation movements: one adding items in a stock for a non-zero price, and another adding items in the same stock for a zero price, the second movement is recorded in the `stock` SQL table with a NULL `total_price`. This creates issues when computing stock value using the FIFO method: the total stock value would show as zero in the case described above. This behaviour is due to operations on NULLs in SQL propagating the NULL value (eg. 1 + NULL = NULL), which is not what is expected when computing stocks. This commit treats all NULL prices as zeroes when requesting a stock value using the FIFO method, which fixes calculation in a right way.
Showing
Please register or sign in to comment