summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-11-29 12:10:14 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-11-29 12:10:14 +0700
commit3327fbccee4c6c95df325b515a7a42b6f937d381 (patch)
treebd7cf59e015006dcd2a3d44e38864e42c3aa902c
parent77945b5d2a3e8e366ca767bef9b9bce137ffee47 (diff)
add expired date on wati
-rw-r--r--indoteknik_custom/models/wati.py29
-rw-r--r--indoteknik_custom/views/wati_history.xml24
2 files changed, 51 insertions, 2 deletions
diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py
index bb6f2293..1e6ac17f 100644
--- a/indoteknik_custom/models/wati.py
+++ b/indoteknik_custom/models/wati.py
@@ -77,6 +77,7 @@ class WatiNotification(models.Model):
return new_header
def _create_wati_history_line(self, new_header, ticket_id, sender_name, notification_json, date_wati):
+ text_body = notification_json['text'] or ''
param_line = {
"wati_history_id": new_header.id,
"conversation_id": notification_json['conversationId'],
@@ -89,13 +90,22 @@ class WatiNotification(models.Model):
"sender_name": sender_name or '',
# "source_url": notification_json['sourceUrl'] or '',
"status_string": notification_json['statusString'] or '',
- "text": notification_json['text'] or '',
+ "text": text_body,
"ticket_id": ticket_id,
"type": notification_json['type'] or '',
"wa_id": notification_json['waId'] or '',
"date_wati": date_wati or '',
}
self.env['wati.history.line'].create([param_line])
+ new_header.last_reply_by = sender_name
+ new_header.last_reply_date = date_wati
+ new_header.last_reply_text = text_body
+ if sender_name == 'Indoteknik':
+ current_time = date_wati
+ # current_time_str = current_time.strftime('%Y-%m-%d %H:%M:%S')
+ delta_time = current_time + timedelta(days=1)
+ # delta_time_str = delta_time.strftime('%Y-%m-%d %H:%M:%S')
+ new_header.expired_date = delta_time
return
def _convert_to_leads(self):
@@ -173,6 +183,23 @@ class WatiHistory(models.Model):
text = fields.Char(string='Text')
date_wati = fields.Datetime(string='Date WATI')
wati_lines = fields.One2many('wati.history.line', 'wati_history_id', string='Lines', auto_join=True)
+ last_reply_by = fields.Char(string='Last Reply by')
+ last_reply_text = fields.Char(string='Last Reply Text')
+ last_reply_date = fields.Datetime(string='Last Reply Date')
+ expired_date = fields.Datetime(string='Expired Date')
+
+ # @api.onchange('last_reply_date')
+ # def _compute_expired_date(self):
+ # if self.last_reply_by == 'Indoteknik':
+ # return
+ # else:
+ # print(1)
+ # current_time = self.last_reply_date
+ # # current_time_str = current_time.strftime('%Y-%m-%d %H:%M:%S')
+ # delta_time = current_time + timedelta(days=1)
+ # # delta_time_str = delta_time.strftime('%Y-%m-%d %H:%M:%S')
+ # self.expired_date = delta_time
+ # return
class WatiHistoryLine(models.Model):
_name = 'wati.history.line'
diff --git a/indoteknik_custom/views/wati_history.xml b/indoteknik_custom/views/wati_history.xml
index 0b805ac5..1b9acc92 100644
--- a/indoteknik_custom/views/wati_history.xml
+++ b/indoteknik_custom/views/wati_history.xml
@@ -11,6 +11,10 @@
<field name="sender_name" readonly="1"/>
<field name="wa_id" readonly="1"/>
<field name="text" readonly="1"/>
+ <field name="last_reply_by" readonly="1" optional="hide"/>
+ <field name="last_reply_date" readonly="1" optional="hide"/>
+ <field name="last_reply_text" readonly="1" optional="hide"/>
+ <field name="expired_date" readonly="1" optional="hide"/>
</tree>
</field>
</record>
@@ -52,10 +56,14 @@
<field name="ticket_id" readonly="1"/>
<field name="sender_name" readonly="1"/>
<field name="text" readonly="1"/>
+ <field name="wa_id" readonly="1"/>
</group>
<group>
<field name="conversation_id" readonly="1"/>
- <field name="wa_id" readonly="1"/>
+ <field name="last_reply_by" readonly="1"/>
+ <field name="last_reply_date" readonly="1"/>
+ <field name="expired_date" readonly="1"/>
+ <field name="last_reply_text" readonly="1"/>
</group>
</group>
<notebook>
@@ -68,10 +76,24 @@
</field>
</record>
+ <record id="view_wati_history_filter" model="ir.ui.view">
+ <field name="name">wati.history.list.select</field>
+ <field name="model">wati.history</field>
+ <field name="priority" eval="15"/>
+ <field name="arch" type="xml">
+ <search string="Search Wati">
+ <field name="sender_name"/>
+ <field name="wa_id"/>
+ <field name="text"/>
+ </search>
+ </field>
+ </record>
+
<record id="wati_history_action" model="ir.actions.act_window">
<field name="name">Wati History</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wati.history</field>
+ <field name="search_view_id" ref="view_wati_history_filter"/>
<field name="view_mode">tree,form</field>
</record>