Skip to content

Commit

Permalink
[FIX] rma_sale: fix _get_price_unit to handle dropship cases
Browse files Browse the repository at this point in the history
Take negative valuation layers, as are to customers, and we handle dropship cases where will have negative and positive layers
  • Loading branch information
AlexPForgeFlow committed Sep 13, 2024
1 parent 2e9bf62 commit 93b827f
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 93b827f

Please sign in to comment.