diff --git a/pms_civitfun/datamodels/pms_checkin_partner.py b/pms_civitfun/datamodels/pms_checkin_partner.py index 857ab663a3..cffae60645 100644 --- a/pms_civitfun/datamodels/pms_checkin_partner.py +++ b/pms_civitfun/datamodels/pms_checkin_partner.py @@ -12,6 +12,7 @@ class CivitfunCheckinPartnerInfo(Datamodel): position = fields.Integer(required=False, allow_none=True) email = fields.String(required=False, allow_none=True) lang = fields.String(required=False, allow_none=True) + language = fields.String(required=False, allow_none=True) name = fields.String(required=False, allow_none=True) surname = fields.String(required=False, allow_none=True) secondSurname = fields.String(required=False, allow_none=True) diff --git a/pms_civitfun/http.py b/pms_civitfun/http.py index dfec865856..30e426bb35 100644 --- a/pms_civitfun/http.py +++ b/pms_civitfun/http.py @@ -7,7 +7,6 @@ Unauthorized, ) -import odoo from odoo.exceptions import ( AccessDenied, AccessError, @@ -18,11 +17,7 @@ from odoo.http import HttpRequest, Root, SessionExpiredException from odoo.loglevels import ustr -from odoo.addons.base_rest.http import ( - HttpRestRequest, - _rest_services_routes, - wrapJsonException, -) +from odoo.addons.base_rest.http import HttpRestRequest, wrapJsonException class HttpRestRequestCivitfun(HttpRestRequest): @@ -72,34 +67,21 @@ def _handle_exception(self, exception): def get_request(self, httprequest): - db = httprequest.session.db - if db and odoo.service.db.exp_db_exist(db): - # on the very first request processed by a worker, - # registry is not loaded yet - # so we enforce its loading here to make sure that - # _rest_services_databases is not empty - odoo.registry(db) - rest_routes = _rest_services_routes.get(db, []) - for root_path in rest_routes: - if httprequest.path.startswith(root_path): - if "civitfun" in httprequest.path: - if ( - "Civitfun-Standard3-Request" in httprequest.environ - and httprequest.environ.get("Civitfun-Standard3-Request") - == "authorization" - ): - httprequest.environ["HTTP_AUTHORIZATION"] = httprequest.environ[ - "Civitfun-Standard3-Request" - ] - if ( - "CONTENT_TYPE" in httprequest.environ - and httprequest.environ.get("CONTENT_TYPE") - == "application/json" - ): - httprequest.environ[ - "CONTENT_TYPE" - ] = "application/json-civitfun" - return HttpRestRequestCivitfun(httprequest) + if "civitfun" in httprequest.path: + if ( + "HTTP_CIVITFUN_STANDARD3_REQUEST" in httprequest.environ + and httprequest.environ.get("Civitfun-Standard3-Request") == "authorization" + ): + httprequest.environ["HTTP_AUTHORIZATION"] = httprequest.environ[ + "Civitfun-Standard3-Request" + ] + if ( + "CONTENT_TYPE" in httprequest.environ + and httprequest.environ.get("CONTENT_TYPE") == "application/json" + and not len(httprequest.get_data().decode(httprequest.charset)) > 0 + ): + httprequest.environ["CONTENT_TYPE"] = "application/json-civitfun" + return HttpRestRequestCivitfun(httprequest) return ori_get_request(self, httprequest) diff --git a/pms_civitfun/services/pms_checkin_partner_service.py b/pms_civitfun/services/pms_checkin_partner_service.py index 8424d007b9..a40f1ab85f 100644 --- a/pms_civitfun/services/pms_checkin_partner_service.py +++ b/pms_civitfun/services/pms_checkin_partner_service.py @@ -136,7 +136,9 @@ def _mapped_hosts_info(self, guest): if guest.customFields.get("phone"): checkin_vals["phone"] = guest.customFields.get("phone") if guest.customFields.get("address"): - checkin_vals["residence_street"] = guest.customFields.get("address") + checkin_vals["residence_street"] = guest.customFields.get( + "address" + ).splitlines()[0] res_zip = False if guest.customFields.get("postalCode"): zip_code = guest.customFields.get("postalCode") @@ -174,10 +176,10 @@ def _mapped_hosts_info(self, guest): .id ) - partner_vals = { - "lang": self._get_mapped_lang(guest.lang), - } - + # partner_vals = { + # "lang": self._get_mapped_lang(guest.lang), + # } + partner_vals = {} return checkin_vals, partner_vals def check_reservation(self, reservation): @@ -197,8 +199,8 @@ def _get_mapped_lang(self, lang): ("iso_code", "=", lang), ] ) - ).code - return pms_lang or False + ) + return pms_lang.code or False def _get_mapped_gender(self, gender): if gender == "M":