mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] pms-api-rest: change param timestamp
This commit is contained in:
committed by
Darío Lodeiros
parent
0b44701b1d
commit
65fe97a07e
@@ -5,14 +5,14 @@ from odoo.addons.datamodel.core import Datamodel
|
||||
|
||||
class PmsNotificationSearch(Datamodel):
|
||||
_name = "pms.notification.search"
|
||||
pmsPropertyId = fields.Integer(required=False)
|
||||
fromDateTime = fields.String(required=False)
|
||||
fromTimestamp = fields.String(required=False)
|
||||
|
||||
|
||||
class PmsNotificationInfo(Datamodel):
|
||||
_name = "pms.notification.info"
|
||||
folioId = fields.Integer(required=False)
|
||||
dateTime = fields.String(required=False)
|
||||
userId = fields.Integer(required=False)
|
||||
mensaje = fields.String(required=False)
|
||||
pmsPropertyId = fields.Integer(required=False)
|
||||
folioId = fields.Integer(required=False)
|
||||
timeStamp = fields.Integer(required=False)
|
||||
folioName = fields.String(required=False)
|
||||
partnerName = fields.String(required=False)
|
||||
saleChannelName = fields.String(required=False)
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
from datetime import datetime
|
||||
|
||||
import pytz
|
||||
|
||||
from odoo import _
|
||||
import datetime
|
||||
|
||||
from odoo.addons.base_rest import restapi
|
||||
from odoo.addons.base_rest_datamodel.restapi import Datamodel
|
||||
@@ -30,18 +26,18 @@ class PmsNotificationService(Component):
|
||||
cors="*",
|
||||
)
|
||||
def get_notifications(self, pms_notification_search):
|
||||
from_datetime = datetime.strptime(
|
||||
pms_notification_search.fromDateTime, "%Y-%m-%d %H:%M:%S"
|
||||
from_date_time = datetime.datetime.fromtimestamp(
|
||||
int(pms_notification_search.fromTimestamp) / 1000
|
||||
)
|
||||
timezone = pytz.timezone(self.env.user.tz or "UTC")
|
||||
from_datetime = timezone.localize(from_datetime)
|
||||
from_datetime_utc = from_datetime.astimezone(pytz.utc)
|
||||
new_reservations = self.env["pms.reservation"].search(
|
||||
[
|
||||
("create_date", ">=", from_datetime_utc),
|
||||
("pms_property_id.id", "=", pms_notification_search.pmsPropertyId),
|
||||
("create_date", ">=", from_date_time),
|
||||
("to_assign", "=", True),
|
||||
("create_uid.id", "!=", self.env.user.id),
|
||||
(
|
||||
"create_uid.id",
|
||||
"!=",
|
||||
self.env.user.id,
|
||||
),
|
||||
],
|
||||
limit=10,
|
||||
order="create_date desc",
|
||||
@@ -53,18 +49,12 @@ class PmsNotificationService(Component):
|
||||
PmsNotificationInfo(
|
||||
pmsPropertyId=folio.pms_property_id.id,
|
||||
folioId=folio.id,
|
||||
dateTime=pytz.UTC.localize(folio.create_date)
|
||||
.astimezone(timezone)
|
||||
.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
userId=folio.create_uid.id,
|
||||
mensaje=_("%s: Nueva reserva de %s por %s")
|
||||
% (
|
||||
folio.name,
|
||||
folio.partner_name,
|
||||
folio.agency_id.name
|
||||
if folio.agency_id
|
||||
else folio.sale_channel_origin_id.name,
|
||||
),
|
||||
timeStamp=int(folio.create_date.strftime("%s%f")) / 1000,
|
||||
folioName=folio.name,
|
||||
partnerName=folio.partner_name,
|
||||
saleChannelName=folio.agency_id.name
|
||||
if folio.agency_id
|
||||
else folio.sale_channel_origin_id.name,
|
||||
)
|
||||
)
|
||||
return notifications
|
||||
|
||||
Reference in New Issue
Block a user