From 716d616a3a3738e2651b6f45c859c8ce9276d0c8 Mon Sep 17 00:00:00 2001 From: Valentin Chevalier Date: Tue, 1 Jun 2021 12:25:01 +0000 Subject: [PATCH] [IMP] sale: add the qty to deliver only in the reporting view Currently, user needs to extract the report and compute the quantity to deliver through a spreadsheet. Task #2537839 closes odoo/odoo#71549 Signed-off-by: Yannick Tivisse (yti) --- addons/pos_sale/report/sale_report.py | 1 + addons/sale/report/sale_report.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/addons/pos_sale/report/sale_report.py b/addons/pos_sale/report/sale_report.py index cda5e0b6d33..26836622374 100644 --- a/addons/pos_sale/report/sale_report.py +++ b/addons/pos_sale/report/sale_report.py @@ -28,6 +28,7 @@ class SaleReport(models.Model): t.uom_id AS product_uom, sum(l.qty) AS product_uom_qty, sum(l.qty) AS qty_delivered, + 0 as qty_to_deliver, CASE WHEN pos.state = 'invoiced' THEN sum(l.qty) ELSE 0 END AS qty_invoiced, CASE WHEN pos.state != 'invoiced' THEN sum(l.qty) ELSE 0 END AS qty_to_invoice, SUM(l.price_subtotal_incl) / MIN(CASE COALESCE(pos.currency_rate, 0) WHEN 0 THEN 1.0 ELSE pos.currency_rate END) AS price_total, diff --git a/addons/sale/report/sale_report.py b/addons/sale/report/sale_report.py index db5e9c71db5..98f7909acf2 100644 --- a/addons/sale/report/sale_report.py +++ b/addons/sale/report/sale_report.py @@ -21,6 +21,7 @@ class SaleReport(models.Model): product_id = fields.Many2one('product.product', 'Product Variant', readonly=True) product_uom = fields.Many2one('uom.uom', 'Unit of Measure', readonly=True) product_uom_qty = fields.Float('Qty Ordered', readonly=True) + qty_to_deliver = fields.Float('Qty To Deliver', readonly=True) qty_delivered = fields.Float('Qty Delivered', readonly=True) qty_to_invoice = fields.Float('Qty To Invoice', readonly=True) qty_invoiced = fields.Float('Qty Invoiced', readonly=True) @@ -67,6 +68,7 @@ class SaleReport(models.Model): t.uom_id as product_uom, CASE WHEN l.product_id IS NOT NULL THEN sum(l.product_uom_qty / u.factor * u2.factor) ELSE 0 END as product_uom_qty, CASE WHEN l.product_id IS NOT NULL THEN sum(l.qty_delivered / u.factor * u2.factor) ELSE 0 END as qty_delivered, + CASE WHEN l.product_id IS NOT NULL THEN SUM((l.product_uom_qty - l.qty_delivered) / u.factor * u2.factor) ELSE 0 END as qty_to_deliver, CASE WHEN l.product_id IS NOT NULL THEN sum(l.qty_invoiced / u.factor * u2.factor) ELSE 0 END as qty_invoiced, CASE WHEN l.product_id IS NOT NULL THEN sum(l.qty_to_invoice / u.factor * u2.factor) ELSE 0 END as qty_to_invoice, CASE WHEN l.product_id IS NOT NULL THEN sum(l.price_total / CASE COALESCE(s.currency_rate, 0) WHEN 0 THEN 1.0 ELSE s.currency_rate END) ELSE 0 END as price_total,