Use product cost price from stock move for cost history
When the product cost price is filled, it must be used instead of the cost price.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Use product cost price from stock move for cost history
|
||||
|
||||
Version 6.8.0 - 2023-05-01
|
||||
--------------------------
|
||||
|
||||
@@ -99,14 +99,15 @@ class ProductCostHistory(ModelSQL, ModelView):
|
||||
None: (move, None),
|
||||
})
|
||||
|
||||
cost_price = Coalesce(move.product_cost_price, move.cost_price)
|
||||
if database.has_window_functions():
|
||||
window = Window(
|
||||
[move.effective_date, move.product],
|
||||
frame='ROWS', start=None, end=None,
|
||||
order_by=[move.write_date.asc, move.id.asc])
|
||||
cost_price = LastValue(move.cost_price, window=window)
|
||||
cost_price = LastValue(cost_price, window=window)
|
||||
else:
|
||||
cost_price = cls.cost_price.sql_cast(move.cost_price)
|
||||
cost_price = cls.cost_price.sql_cast(cost_price)
|
||||
|
||||
move_history = convert_from(None, tables, type_='INNER').select(
|
||||
(move.id * 2).as_('id'),
|
||||
|
||||
Reference in New Issue
Block a user