Skip to content

Commit

Permalink
Merge pull request #540 from ForgeFlow/16.0-fix-HD-12512
Browse files Browse the repository at this point in the history
[FIX] rma_sale: fix _get_price_unit to handle dropship cases
  • Loading branch information
AlexPForgeFlow authored Nov 6, 2024
2 parents 647e1b6 + 93b827f commit bb16136
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rma_sale/models/rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,13 @@ def _get_price_unit(self):
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")
Expand Down

0 comments on commit bb16136

Please sign in to comment.