diff options
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring_detail.py | 11 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_monitoring_detail.xml | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index a393f81d..405b43ef 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -1,4 +1,7 @@ from odoo import fields, models, api, tools +import logging + +_logger = logging.getLogger(__name__) class SaleMonitoringDetail(models.Model): @@ -19,8 +22,14 @@ class SaleMonitoringDetail(models.Model): date_order = fields.Datetime(string="Date Order") status = fields.Char(string="Status") + def refresh_mv(self): + _logger.info('Refresh Materialized View Starting...') + self.env.cr.execute("REFRESH MATERIALIZED VIEW sale_monitoring_detail") + _logger.info("Refresh Materialized View berhasil") + def init(self): - tools.drop_view_if_exists(self.env.cr, self._table) + # tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute("DROP MATERIALIZED VIEW sale_monitoring_detail CASCADE") self.env.cr.execute(""" CREATE MATERIALIZED VIEW %s AS ( SELECT diff --git a/indoteknik_custom/views/sale_monitoring_detail.xml b/indoteknik_custom/views/sale_monitoring_detail.xml index 9e4734d3..cd87bc1a 100755 --- a/indoteknik_custom/views/sale_monitoring_detail.xml +++ b/indoteknik_custom/views/sale_monitoring_detail.xml @@ -22,6 +22,7 @@ decoration-success="status == 'SIAP KIRIM' or status == 'KIRIM SISANYA'" decoration-info="status == 'Belum Invoiced'" /> + <button name="refresh_mv" string="Refresh" class="oe_highlight" type="object"/> </tree> </field> </record> |
