Skip to content

Commit

Permalink
Merge PR #290 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by rafaelbn
  • Loading branch information
OCA-git-bot committed Nov 6, 2024
2 parents c8e3a02 + cc9d922 commit 391e235
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions sale_report_delivered/reports/sale_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,32 @@ def _select(self):
sub.picking_id,
sum(signed_qty * unsigned_product_uom_qty) AS product_uom_qty,
sum(signed_qty * unsigned_price_subtotal) AS price_subtotal,
sum(COALESCE(-sub.amount_cost, signed_qty *
ROUND(sub.unsigned_purchase_price * unsigned_product_uom_qty,
sub.decimal_places))) AS amount_cost,
sum(signed_qty * unsigned_price_subtotal - COALESCE(-sub.amount_cost, signed_qty *
ROUND(sub.unsigned_purchase_price * unsigned_product_uom_qty,
sub.decimal_places))) AS margin,
CASE
WHEN BOOL_OR(sub.amount_cost is not NULL)
THEN sum(-sub.amount_cost)
ELSE sum(
signed_qty * ROUND(
sub.unsigned_purchase_price * unsigned_product_uom_qty,
sub.decimal_places
)
)
END AS amount_cost,
CASE
WHEN BOOL_OR(sub.amount_cost is not NULL)
THEN sum(
signed_qty * unsigned_price_subtotal + COALESCE(
sub.amount_cost, 0.0
)
)
ELSE sum(
signed_qty * unsigned_price_subtotal - (
signed_qty * ROUND(
sub.unsigned_purchase_price * unsigned_product_uom_qty,
sub.decimal_places
)
)
)
END AS margin,
0 AS margin_percent
"""
return select_str
Expand Down

0 comments on commit 391e235

Please sign in to comment.