feat: convert loyalty point creation date to Asia/Jakarta timezone for display

This commit is contained in:
Suherdy Yacob 2026-06-15 16:21:01 +07:00
parent 4981764a5f
commit c9f25b4dae

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import pytz
from odoo import http from odoo import http
from odoo.http import request from odoo.http import request
@ -261,9 +262,19 @@ class AppNotificationController(http.Controller):
program_type = card_info.get('program_type') or 'loyalty' program_type = card_info.get('program_type') or 'loyalty'
program_name = card_info.get('program_name') or '' program_name = card_info.get('program_name') or ''
create_date = rec.get('create_date')
if create_date:
if create_date.tzinfo is None:
create_date = pytz.utc.localize(create_date)
wib_tz = pytz.timezone('Asia/Jakarta')
create_date = create_date.astimezone(wib_tz)
date_str = create_date.strftime('%Y-%m-%d %H:%M:%S')
else:
date_str = ''
result.append({ result.append({
'id': rec['id'], 'id': rec['id'],
'date': str(rec.get('create_date') or ''), 'date': date_str,
'points': round(float(points), 2), 'points': round(float(points), 2),
'type': point_type, 'type': point_type,
'order_ref': order_ref, 'order_ref': order_ref,