summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-05-17 15:01:34 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-05-17 15:01:34 +0700
commit1545c0341e36811ad23d4b465e2e5194f7b0162a (patch)
tree11c881332ad946c18f8106543fe57413fa945b14
parentb7387d281425da2a72f202aac78c5800866a7117 (diff)
fix sale monitoring
-rwxr-xr-xindoteknik_custom/models/sale_monitoring_detail.py28
-rwxr-xr-xindoteknik_custom/views/sale_monitoring_detail.xml3
2 files changed, 4 insertions, 27 deletions
diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py
index 82bd5c48..5fd8e47a 100755
--- a/indoteknik_custom/models/sale_monitoring_detail.py
+++ b/indoteknik_custom/models/sale_monitoring_detail.py
@@ -23,26 +23,9 @@ class SaleMonitoringDetail(models.Model):
status = fields.Char(string="Status")
def init(self):
- self._drop_view()
- self.env.cr.execute("SELECT matviewname from pg_matviews where schemaname = 'public' and matviewname = '%s'" % self._table)
- materialized_view = self.env.cr.fetchone()
- if materialized_view is None:
- self._init_materialized_view()
-
- def action_refresh(self):
- _logger.info("Refresh %s View Starting..." % self._table)
- self.env.cr.execute("REFRESH MATERIALIZED VIEW %s" % self._table)
- _logger.info("Refresh %s View Success" % self._table)
-
- def _drop_view(self):
- self.env.cr.execute("SELECT viewname from pg_views where schemaname = 'public' and viewname = '%s'" % self._table)
- standard_view = self.env.cr.fetchone()
- if standard_view is not None:
- self.env.cr.execute("DROP VIEW %s CASCADE" % self._table)
-
- def _init_materialized_view(self):
+ tools.drop_view_if_exists(self.env.cr, self._table)
self.env.cr.execute("""
- CREATE MATERIALIZED VIEW %s AS (
+ CREATE OR REPLACE VIEW %s AS (
SELECT
*,
CASE
@@ -76,10 +59,7 @@ class SaleMonitoringDetail(models.Model):
WHERE pt.type IN ('consu','product')
AND so.state IN ('sale','done')
AND so.create_date >= '2022-08-10'
- and sol.product_uom_qty > get_qty_available(sol.product_id)
- ) a
- WHERE
- a.qty_so_delivered > a.qty_so_invoiced
- or a.qty_to_delivered > 0
+ and so.so_status not in('terproses')
+ ) a
)
""" % self._table)
diff --git a/indoteknik_custom/views/sale_monitoring_detail.xml b/indoteknik_custom/views/sale_monitoring_detail.xml
index d22f0a13..d1d900f6 100755
--- a/indoteknik_custom/views/sale_monitoring_detail.xml
+++ b/indoteknik_custom/views/sale_monitoring_detail.xml
@@ -5,9 +5,6 @@
<field name="model">sale.monitoring.detail</field>
<field name="arch" type="xml">
<tree create="false" multi_edit="1">
- <header>
- <button name="action_refresh" string="Refresh" class="oe_highlight" type="object" />
- </header>
<field name="date_order"/>
<field name="sale_order_id"/>
<field name="partner_id"/>