From 56ddfdaa6a3ea80ef7c17556af26bf2980ac09ca Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Fri, 14 Apr 2023 13:07:47 +0000 Subject: [PATCH] [FIX] payment: initialize txContext before await Steps to reproduce: - install website_sale; - install website_sale_picking; - enable just "Pay in store when picking the product" provider; - pusblish just "[On Site Pick] My Shop 1" shipping method; - go to ecommerce and make the purchase flow. Issue: A traceback appears on the "/shop/payment" page. Cause: We use the `txContext` field in the `_setPaymentFlow` method before it is initialized. Indeed during the `start` method, we have to wait for the end of the super before `txContext` is initialized. Since the `start` method is asynchronous, this will not block the `_setPaymentFlow` method call which will use the uninitialized field. opw-3257641 closes odoo/odoo#119351 X-original-commit: 18b629bfc26ab69e5e3bdc8aac090de66cf13f36 Signed-off-by: Antoine Vandevenne (anv) Signed-off-by: Lefebvre Thomas (thle) --- addons/payment/static/src/js/payment_form_mixin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/payment/static/src/js/payment_form_mixin.js b/addons/payment/static/src/js/payment_form_mixin.js index d2ff5f1c66e..55176781dc7 100644 --- a/addons/payment/static/src/js/payment_form_mixin.js +++ b/addons/payment/static/src/js/payment_form_mixin.js @@ -31,6 +31,8 @@ * @override */ start: async function () { + this.txContext = {}; // Synchronously initialize txContext before any await. + Object.assign(this.txContext, this.$el.data()); await this._super(...arguments); window.addEventListener('pageshow', function (event) { if (event.persisted) { @@ -38,8 +40,6 @@ } }); this.$('[data-bs-toggle="tooltip"]').tooltip(); - this.txContext = {}; - Object.assign(this.txContext, this.$el.data()); const $checkedRadios = this.$('input[name="o_payment_radio"]:checked'); if ($checkedRadios.length === 1) { const checkedRadio = $checkedRadios[0];