diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-02-21 13:33:01 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-02-21 13:33:01 +0700 |
| commit | bdb9f28bb5b295b2a5dc5b116d67a561b9947e4a (patch) | |
| tree | 226a75e5fbbc24adc261983acdb8bcb16ed50792 /indoteknik_custom/models/wati.py | |
| parent | c2105f6b0efdd0bb74b934205bb0acc43b297bdc (diff) | |
| parent | 861bb64e5a972b8ce9b09d2345dbb6250d041435 (diff) | |
Merge branch 'release' into midtrans
Diffstat (limited to 'indoteknik_custom/models/wati.py')
| -rw-r--r-- | indoteknik_custom/models/wati.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index e2e723ef..df467ea1 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -1,4 +1,5 @@ from odoo import fields, models, api +from datetime import datetime, timedelta import logging import json @@ -11,6 +12,18 @@ class WatiNotification(models.Model): json_raw = fields.Char(string='JSON Raw Text') is_lead = fields.Boolean(string='To Leads', help='apakah sudah ter-convert jadi leads') + def _cleanup(self): + current_time = datetime.now() + delta_time = current_time - timedelta(days=15) + + delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') + self.env['wati.notification'].search([ + ('create_date', '<', delta_time), + ('is_lead', '=', True), + ]).unlink() + _logger.info('Success Cleanup WATI Notification') + + def _convert_to_leads(self): query = [ ('is_lead', '=', False) |
