mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[FIX] rma_sale: fix _get_price_unit to handle dropship cases
Take negative valuation layers, as are to customers, and we handle dropship cases where will have negative and positive layers
This commit is contained in:
@@ -232,7 +232,13 @@ class RmaOrderLine(models.Model):
|
||||
and x.location_dest_id.usage == "customer"
|
||||
)
|
||||
if moves:
|
||||
layers = moves.sudo().mapped("stock_valuation_layer_ids")
|
||||
# We take negative valuation layers, as are to customers,
|
||||
# and we handle dropship cases where will have negative and positive layers
|
||||
layers = (
|
||||
moves.sudo()
|
||||
.mapped("stock_valuation_layer_ids")
|
||||
.filtered(lambda layer: layer.quantity < 0 and layer.value < 0)
|
||||
)
|
||||
if layers:
|
||||
price_unit = sum(layers.mapped("value")) / sum(
|
||||
layers.mapped("quantity")
|
||||
|
||||
Reference in New Issue
Block a user