diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-10-05 11:27:01 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-10-05 11:27:01 +0700 |
| commit | 3abd0ca6790b9a278f9ddd52b063691b99d6916c (patch) | |
| tree | 87c3d8261edf3eff40b556262ddbe51c68e877a5 | |
| parent | 77a6833006f406ffc7ddd5d50308c843cf9133a5 (diff) | |
Update sale_monitoring.py and sale_monitoring_detail.py
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring.py | 12 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring_detail.py | 73 |
2 files changed, 43 insertions, 42 deletions
diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index 2ef23f39..a837a6bc 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -35,12 +35,12 @@ class SaleMonitoring(models.Model): SUM(smd.qty_so_delivered) AS qty_so_delivered, SUM(smd.qty_so_invoiced) AS qty_so_invoiced, CASE - WHEN SUM(qty_po) <> SUM(qty_so) AND SUM(qty_po) <= 0 THEN 'Belum PO sama sekali' - WHEN SUM(qty_po) <> SUM(qty_so) THEN 'Belum PO full' - WHEN SUM(qty_po_received) <> SUM(qty_po) AND SUM(qty_po_received) <= 0 THEN 'Belum Received sama sekali' - WHEN SUM(qty_po_received) <> SUM(qty_po) THEN 'Belum Received full' - WHEN SUM(qty_so_delivered) <> SUM(qty_so) AND SUM(qty_so_delivered) <= 0 THEN 'SIAP KIRIM' - WHEN SUM(qty_so_delivered) <> SUM(qty_so) THEN 'KIRIM SISANYA' + WHEN SUM(qty_po) < SUM(qty_so) AND SUM(qty_po) <= 0 THEN 'Belum PO sama sekali' + WHEN SUM(qty_po) < SUM(qty_so) THEN 'Belum PO full' + WHEN SUM(qty_po_received) < SUM(qty_so) AND SUM(qty_po_received) <= 0 THEN 'Belum Received sama sekali' + WHEN SUM(qty_po_received) < SUM(qty_so) THEN 'Belum Received full' + WHEN SUM(qty_to_delivered) = SUM(qty_so) THEN 'SIAP KIRIM' + WHEN SUM(qty_to_delivered) < SUM(qty_so) and SUM(qty_to_delivered) > 0 THEN 'KIRIM SISANYA' ELSE 'Belum Invoiced' END AS status, get_po_number(smd.sale_order_id) as po_number diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index d80ec99b..843c7348 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -23,41 +23,42 @@ class SaleMonitoringDetail(models.Model): tools.drop_view_if_exists(self.env.cr, self._table) self.env.cr.execute(""" CREATE OR REPLACE VIEW %s AS ( + SELECT + *, + CASE + WHEN qty_po < qty_so AND qty_po <= 0 THEN 'Belum PO sama sekali' + WHEN qty_po < qty_so THEN 'Belum PO full' + WHEN qty_po_received < qty_so and qty_po_received <= 0 THEN 'Belum Received sama sekali' + WHEN qty_po_received < qty_so THEN 'Belum Received full' + WHEN qty_to_delivered = qty_so THEN 'SIAP KIRIM' + WHEN qty_to_delivered < qty_so and qty_to_delivered > 0 THEN 'KIRIM SISANYA' + ELSE 'Belum Invoiced' + END AS status + FROM + ( SELECT - *, - CASE - WHEN qty_po <> qty_so AND qty_po <= 0 THEN 'Belum PO sama sekali' - WHEN qty_po <> qty_so THEN 'Belum PO full' - WHEN qty_po_received <> qty_po and qty_po_received <= 0 THEN 'Belum Received sama sekali' - WHEN qty_po_received <> qty_po THEN 'Belum Received full' - WHEN qty_so_delivered <> qty_so AND qty_so_delivered <= 0 THEN 'SIAP KIRIM' - WHEN qty_so_delivered <> qty_so THEN 'KIRIM SISANYA' - ELSE 'Belum Invoiced' - END AS status - FROM - ( - SELECT - p.id AS id, - so.id AS sale_order_id, - so.partner_id as partner_id, - so.user_id, - p.id AS product_id, - sol.product_uom_qty AS qty_so, - sol.qty_delivered AS qty_so_delivered, - sol.qty_invoiced AS qty_so_invoiced, - so.date_order AS date_order, - get_qty_po(so.id, sol.product_id) AS qty_po, - get_qty_received(so.id, sol.product_id) AS qty_po_received - FROM sale_order so - JOIN sale_order_line sol ON sol.order_id = so.id - JOIN product_product p ON p.id = sol.product_id - JOIN product_template pt ON pt.id = p.product_tmpl_id - WHERE pt.type IN ('consu','product') - AND so.state IN ('sale','done') - AND so.create_date >= '2022-08-10' - ) a - WHERE - a.qty_so <> a.qty_so_delivered - OR a.qty_so <> a.qty_so_invoiced - ) + p.id AS id, + so.id AS sale_order_id, + so.partner_id as partner_id, + so.user_id, + p.id AS product_id, + sol.product_uom_qty AS qty_so, + sol.qty_delivered AS qty_so_delivered, + get_qty_to_delivered(sol.id) as qty_to_delivered, + sol.qty_invoiced AS qty_so_invoiced, + so.date_order AS date_order, + get_qty_po(so.id, sol.product_id) AS qty_po, + get_qty_received(so.id, sol.product_id) AS qty_po_received + FROM sale_order so + JOIN sale_order_line sol ON sol.order_id = so.id + JOIN product_product p ON p.id = sol.product_id + JOIN product_template pt ON pt.id = p.product_tmpl_id + WHERE pt.type IN ('consu','product') + AND so.state IN ('sale','done') + AND so.create_date >= '2022-08-10' + ) a + WHERE + a.qty_so_delivered > a.qty_so_invoiced + or a.qty_to_delivered > 0 + ) """ % self._table) |
