diff --git a/pms/controllers/pms_portal.py b/pms/controllers/pms_portal.py index 9cfb9f05b..76ef4fb59 100644 --- a/pms/controllers/pms_portal.py +++ b/pms/controllers/pms_portal.py @@ -673,14 +673,16 @@ class PortalAccount(PortalAccount): invoice, access_token, **kwargs ) acquirers = values.get("acquirers") - for acquirer in acquirers: - if ( - acquirer.pms_property_ids - and invoice.pms_property_id.id not in acquirer.pms_property_ids.ids - ): - values["acquirers"] -= acquirer + if acquirers: + for acquirer in acquirers: + if ( + acquirer.pms_property_ids + and invoice.pms_property_id.id not in acquirer.pms_property_ids.ids + ): + values["acquirers"] -= acquirer payment_tokens = values.get("payment_tokens") - for pms in payment_tokens: - if pms.acquirer_id not in values["acquirers"].ids: - values["pms"] -= pms + if payment_tokens: + for pms in payment_tokens: + if pms.acquirer_id not in values["acquirers"].ids: + values["pms"] -= pms return values diff --git a/pms/static/src/js/folio_portal_sidebar.js b/pms/static/src/js/folio_portal_sidebar.js new file mode 100644 index 000000000..629f71f89 --- /dev/null +++ b/pms/static/src/js/folio_portal_sidebar.js @@ -0,0 +1,74 @@ +odoo.define("account.FolioPortalSidebar", function (require) { + "use strict"; + + const dom = require("web.dom"); + var publicWidget = require("web.public.widget"); + var PortalSidebar = require("portal.PortalSidebar"); + var utils = require("web.utils"); + + publicWidget.registry.FolioPortalSidebar = PortalSidebar.extend({ + selector: ".o_portal_folio_sidebar", + events: { + "click .o_portal_folio_print": "_onPrintFolio", + }, + + /** + * @override + */ + start: function () { + var def = this._super.apply(this, arguments); + + var $folioHtml = this.$el.find("iframe#folio_html"); + var updateIframeSize = this._updateIframeSize.bind(this, $folioHtml); + + $(window).on("resize", updateIframeSize); + + var iframeDoc = + $folioHtml[0].contentDocument || $folioHtml[0].contentWindow.document; + if (iframeDoc.readyState === "complete") { + updateIframeSize(); + } else { + $folioHtml.on("load", updateIframeSize); + } + + return def; + }, + + // -------------------------------------------------------------------------- + // Handlers + // -------------------------------------------------------------------------- + + /** + * Called when the iframe is loaded or the window is resized on customer portal. + * The goal is to expand the iframe height to display the full report without scrollbar. + * + * @private + * @param {Object} $el: the iframe + */ + _updateIframeSize: function ($el) { + var $wrapwrap = $el.contents().find("div#wrapwrap"); + // Set it to 0 first to handle the case where scrollHeight is too big for its content. + $el.height(0); + $el.height($wrapwrap[0].scrollHeight); + + // Scroll to the right place after iframe resize + if (!utils.isValidAnchor(window.location.hash)) { + return; + } + var $target = $(window.location.hash); + if (!$target.length) { + return; + } + dom.scrollTo($target[0], {duration: 0}); + }, + /** + * @private + * @param {MouseEvent} ev + */ + _onPrintFolio: function (ev) { + ev.preventDefault(); + var href = $(ev.currentTarget).attr("href"); + this._printIframeContent(href); + }, + }); +}); diff --git a/pms/views/assets.xml b/pms/views/assets.xml index 0ff4d6887..adf5c24dc 100644 --- a/pms/views/assets.xml +++ b/pms/views/assets.xml @@ -2,11 +2,13 @@ diff --git a/pms/views/folio_portal_templates.xml b/pms/views/folio_portal_templates.xml index e41bc2def..9cdaf1fee 100644 --- a/pms/views/folio_portal_templates.xml +++ b/pms/views/folio_portal_templates.xml @@ -192,7 +192,7 @@ > -
+
@@ -209,16 +209,16 @@
-
+ - -
- + + Guests to Precheckin + +
+
  • -
    Salesperson
    -
    +
    + + Salesperson + +
    +
    Contact Contact
    -
    +
    Send message + class="fa fa-fw fa-comments" + />Send message
  • @@ -274,7 +283,13 @@ -
    +
    + + +