diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-01-24 13:58:03 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-01-24 13:58:03 +0700 |
| commit | 93d049139c2be8a70d32145a89e8b6e34732d56d (patch) | |
| tree | 86357713102fbfba446e6015b225ec3d2a46b4c0 /indoteknik_custom/models/sale_monitoring.py | |
| parent | da5f5134f56b2ccf1c1de16c3f7616ab3719f3ea (diff) | |
| parent | 3f311b95265adf1902e650b12fba93cf81a7f72d (diff) | |
Merge branch 'release' into feature/rest-api
Diffstat (limited to 'indoteknik_custom/models/sale_monitoring.py')
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring.py | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index a837a6bc..a3265a8b 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -1,5 +1,7 @@ from odoo import fields, models, api, tools +import logging +_logger = logging.getLogger(__name__) class SaleMonitoring(models.Model): _name = 'sale.monitoring' @@ -22,29 +24,35 @@ class SaleMonitoring(models.Model): def init(self): tools.drop_view_if_exists(self.env.cr, self._table) self.env.cr.execute(""" - CREATE OR REPLACE VIEW %s AS ( - SELECT - smd.sale_order_id AS id, - smd.date_order, - smd.sale_order_id, - smd.partner_id, - smd.user_id, - SUM(smd.qty_so) AS qty_so, - SUM(smd.qty_po) AS qty_po, - SUM(smd.qty_po_received) AS qty_po_received, - 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_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 - FROM sale_monitoring_detail smd - GROUP BY smd.date_order, smd.sale_order_id, smd.partner_id, smd.user_id - ) + CREATE OR REPLACE VIEW %s AS ( + SELECT + smd.sale_order_id AS id, + smd.date_order, + smd.sale_order_id, + smd.partner_id, + smd.user_id, + SUM(smd.qty_so) AS qty_so, + SUM(smd.qty_po) AS qty_po, + SUM(smd.qty_po_received) AS qty_po_received, + 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_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 + FROM sale_monitoring_detail smd + GROUP BY smd.date_order, smd.sale_order_id, smd.partner_id, smd.user_id + ) """ % self._table) + + def action_refresh(self): + _logger.info("Refresh %s View Starting..." % self._table) + self.env.cr.execute("REFRESH MATERIALIZED VIEW sale_monitoring_detail") + _logger.info("Refresh %s View Success" % self._table) +
\ No newline at end of file |
