changes
This commit is contained in:
@@ -1,12 +1,28 @@
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from odoo import _, fields, http
|
||||
from odoo.http import request
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools.misc import format_datetime as _odoo_format_datetime
|
||||
|
||||
COMPANY_TZ = 'America/Toronto'
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _fmt_date(env, dt_val, tz=None):
|
||||
"""Format a datetime for portal page display in the company timezone."""
|
||||
if not dt_val:
|
||||
return ''
|
||||
return _odoo_format_datetime(
|
||||
env, dt_val,
|
||||
tz=tz or COMPANY_TZ,
|
||||
dt_format="MMMM dd, yyyy 'at' hh:mm a",
|
||||
)
|
||||
|
||||
|
||||
class FusionRentalController(http.Controller):
|
||||
|
||||
# =================================================================
|
||||
@@ -34,7 +50,9 @@ class FusionRentalController(http.Controller):
|
||||
)
|
||||
|
||||
order = cancel_request.order_id
|
||||
today = fields.Date.today()
|
||||
tz_name = order.company_id.partner_id.tz or COMPANY_TZ
|
||||
tz = ZoneInfo(tz_name)
|
||||
today = datetime.now(timezone.utc).astimezone(tz).date()
|
||||
if order.rental_next_renewal_date and order.rental_next_renewal_date <= today:
|
||||
return request.render(
|
||||
'fusion_rental.cancellation_invalid_page',
|
||||
@@ -63,6 +81,9 @@ class FusionRentalController(http.Controller):
|
||||
'order': order,
|
||||
'partner': cancel_request.partner_id,
|
||||
'token': token,
|
||||
'formatted_return_date': _fmt_date(
|
||||
request.env, order.rental_return_date, tz_name,
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -149,6 +170,7 @@ class FusionRentalController(http.Controller):
|
||||
from odoo.addons.fusion_poynt.utils import clean_application_id
|
||||
poynt_application_id = clean_application_id(raw_app_id) or raw_app_id
|
||||
|
||||
tz_name = order.company_id.partner_id.tz or COMPANY_TZ
|
||||
return request.render(
|
||||
'fusion_rental.agreement_signing_page',
|
||||
{
|
||||
@@ -159,6 +181,12 @@ class FusionRentalController(http.Controller):
|
||||
'google_api_key': google_api_key,
|
||||
'poynt_business_id': poynt_business_id,
|
||||
'poynt_application_id': poynt_application_id,
|
||||
'formatted_start_date': _fmt_date(
|
||||
request.env, order.rental_start_date, tz_name,
|
||||
),
|
||||
'formatted_return_date': _fmt_date(
|
||||
request.env, order.rental_return_date, tz_name,
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user