From 38743b7cea47c609cbf0576cdb8ac1e6d8612511 Mon Sep 17 00:00:00 2001 From: miguelpadin Date: Thu, 7 Sep 2023 12:11:36 +0200 Subject: [PATCH] [IMP] pms-api-rest: add authorImageUrl to folio % reservation messages service --- pms_api_rest/datamodels/pms_reservation_message.py | 2 ++ pms_api_rest/services/pms_folio_service.py | 9 ++++++--- pms_api_rest/services/pms_reservation_service.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pms_api_rest/datamodels/pms_reservation_message.py b/pms_api_rest/datamodels/pms_reservation_message.py index 6ff581da26..3b004d7ed0 100644 --- a/pms_api_rest/datamodels/pms_reservation_message.py +++ b/pms_api_rest/datamodels/pms_reservation_message.py @@ -13,6 +13,7 @@ class PmsReservationMessageInfo(Datamodel): date = fields.String(required=False, allow_none=True) messageType = fields.String(required=False, allow_none=True) authorImageBase64 = fields.String(required=False, allow_none=True) + authorImageUrl = fields.String(required=False, allow_none=True) class PmsFolioMessageInfo(Datamodel): @@ -23,6 +24,7 @@ class PmsFolioMessageInfo(Datamodel): date = fields.String(required=False, allow_none=True) messageType = fields.String(required=False, allow_none=True) authorImageBase64 = fields.String(required=False, allow_none=True) + authorImageUrl = fields.String(required=False, allow_none=True) class PmsMessageInfo(Datamodel): diff --git a/pms_api_rest/services/pms_folio_service.py b/pms_api_rest/services/pms_folio_service.py index 15d847ebd1..698d1a9515 100644 --- a/pms_api_rest/services/pms_folio_service.py +++ b/pms_api_rest/services/pms_folio_service.py @@ -3,6 +3,7 @@ from datetime import datetime, timedelta from odoo import _, fields +from .manage_url_images import url_image from odoo.exceptions import MissingError, ValidationError from odoo.osv import expression from odoo.tools import get_lang @@ -1257,6 +1258,7 @@ def get_folio_reservation_messages(self, folio_id): ).decode("utf-8") if message.author_id.image_1024 else None, + authorImageUrl=url_image(self, 'res.partner', message.author_id.id, 'image_1024'), ) ) PmsFolioMessageInfo = self.env.datamodels["pms.folio.message.info"] @@ -1268,9 +1270,9 @@ def get_folio_reservation_messages(self, folio_id): subject = folio_message.subject if folio_message.subject else None folio_messages.append( PmsFolioMessageInfo( - author=message.author_id.name - if message.author_id - else message.email_from, + author=folio_message.author_id.name + if folio_message.author_id + else folio_message.email_from, message=message_body, subject=subject, date=folio_message.date.strftime("%d/%m/%y %H:%M:%S"), @@ -1280,6 +1282,7 @@ def get_folio_reservation_messages(self, folio_id): ).decode("utf-8") if folio_message.author_id.image_1024 else None, + authorImageUrl=url_image(self, 'res.partner', folio_message.author_id.id, 'image_1024'), ) ) PmsMessageInfo = self.env.datamodels["pms.message.info"] diff --git a/pms_api_rest/services/pms_reservation_service.py b/pms_api_rest/services/pms_reservation_service.py index ccc767817d..50e44e59e9 100644 --- a/pms_api_rest/services/pms_reservation_service.py +++ b/pms_api_rest/services/pms_reservation_service.py @@ -271,7 +271,7 @@ def update_reservation(self, reservation_id, reservation_data): reservation.with_context(skip_compute_service_ids=True).write(reservation_vals) else: reservation.write(reservation_vals) - print(reservation.service_ids.mapped("name")) + # print(reservation.service_ids.mapped("name")) def _get_reservation_lines_mapped(self, origin_data, reservation_line=False):