summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-10-06 08:59:52 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-10-06 08:59:52 +0700
commitd3a28f88b3b94123a3db4ae0873c7e157bbb13f8 (patch)
treec2a383be583f41d80f98ee78fddf0641f1ebefbe /indoteknik_custom/models
parent3d20a65942b64f252a10bada016042a3e1fc498a (diff)
parent1c18f6c7438537a60f181d089df06a0b4ba915f9 (diff)
Merge commit '1c18f6c7438537a60f181d089df06a0b4ba915f9'
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/product_pricelist.py12
-rwxr-xr-xindoteknik_custom/models/sale_monitoring.py12
-rwxr-xr-xindoteknik_custom/models/sale_monitoring_detail.py73
4 files changed, 56 insertions, 42 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 19916fd4..415cd380 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -24,4 +24,5 @@ from . import stock_move
from . import stock_picking
from . import stock_picking_type
from . import delivery_order
+from . import product_pricelist
from . import users
diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py
new file mode 100644
index 00000000..b70eb6e6
--- /dev/null
+++ b/indoteknik_custom/models/product_pricelist.py
@@ -0,0 +1,12 @@
+from odoo import models, fields, api
+from odoo.exceptions import UserError
+
+
+class ProductPricelist(models.Model):
+ _inherit = 'product.pricelist'
+
+ is_flash_sale = fields.Boolean(string='Flash Sale', default=False)
+ banner = fields.Binary(string='Banner')
+ start_date = fields.Datetime(string='Start Date')
+ end_date = fields.Datetime(string='End Date')
+
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)