summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-06-15 11:50:08 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-06-15 11:50:08 +0700
commit1edd55b85c24b8f9a36349fa34793cb65a554851 (patch)
treebb68fafa733d4cdaa4ea61fa6f37267d72691911 /indoteknik_custom/models
parent66acad265bbb7edcc20bfe1cb5ee34dad53f28d9 (diff)
add qty reserved in sale monitoring and sale monitoring detail
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/sale_monitoring.py9
-rwxr-xr-xindoteknik_custom/models/sale_monitoring_detail.py10
2 files changed, 14 insertions, 5 deletions
diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py
index a3265a8b..ea1e490c 100755
--- a/indoteknik_custom/models/sale_monitoring.py
+++ b/indoteknik_custom/models/sale_monitoring.py
@@ -20,6 +20,7 @@ class SaleMonitoring(models.Model):
date_order = fields.Datetime(string="Date Order")
status = fields.Char(string="Status")
po_number = fields.Char(string="PO Number")
+ qty_reserved = fields.Integer(string="Qty Reserved")
def init(self):
tools.drop_view_if_exists(self.env.cr, self._table)
@@ -36,9 +37,13 @@ class SaleMonitoring(models.Model):
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,
+ sum(smd.qty_reserved) as qty_reserved,
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_so) = SUM(qty_reserved) then 'SIAP KIRIM'
+ WHEN SUM(qty_so) = SUM(qty_so_delivered) then 'Delivered'
+ WHEN SUM(qty_so) = SUM(qty_so_invoiced) then 'Done'
+ WHEN SUM(qty_reserved) < SUM(qty_so) and SUM(qty_reserved) > 0 THEN 'Belum PO full'
+ WHEN SUM(qty_reserved) = SUM(qty_so) THEN 'Belum PO sama sekali'
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'
diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py
index a578f67b..908ccb68 100755
--- a/indoteknik_custom/models/sale_monitoring_detail.py
+++ b/indoteknik_custom/models/sale_monitoring_detail.py
@@ -21,6 +21,7 @@ class SaleMonitoringDetail(models.Model):
qty_so_invoiced = fields.Integer(string="Qty SO Invoiced")
date_order = fields.Datetime(string="Date Order")
status = fields.Char(string="Status")
+ qty_reserved = fields.Integer(string="Qty Reserved")
def init(self):
tools.drop_view_if_exists(self.env.cr, self._table)
@@ -29,9 +30,11 @@ class SaleMonitoringDetail(models.Model):
SELECT
*,
CASE
+ WHEN qty_so = qty_reserved then 'SIAP KIRIM'
+ WHEN qty_so = qty_so_delivered then 'Delivered'
WHEN qty_so = qty_so_invoiced then 'Done'
- 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_reserved < qty_so and qty_reserved > 0 THEN 'Belum PO full'
+ WHEN qty_reserved = qty_so THEN 'Belum PO sama sekali'
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'
@@ -52,7 +55,8 @@ class SaleMonitoringDetail(models.Model):
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
+ get_qty_received(so.id, sol.product_id) AS qty_po_received,
+ get_qty_reserved(so.id, sol.product_id) as qty_reserved
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