Ir al contenido
Menú
Se marcó esta pregunta

Hi, I am working on a payment plugin for odoo 16 with an inline form.

I want to show my form only when my payment method is selected. My problem is that if a user select my payment method the "pay now" button go to the state enable for half a second before i can put it back to a disable state.

So, i am looking for the function that enable the button when selecting a provider


Thank you

Avatar
Descartar
Mejor respuesta

Hello Hippolyte Lacour,


Below .js function will trigger initialy when clicked on "Pay Now" Button.

// #=== DOM MANIPULATION ===#


//Code 1 in comment//


After that, it will call the below function.


//Code 2 in Comment//


Hope this helps.

   

If you need any help in customization feel free to contact us.


Thanks & Regards,

Email:  odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

Avatar
Descartar

Code 1 :

/**
* Check if the submit button can be enabled and do it if so.
*
* @private
* @param {boolean} unblockUI - Whether the UI should also be unblocked.
* @return {void}
*/
_enableButton(unblockUI = true) {
console.log('\n\n---third----')
Component.env.bus.trigger('enablePaymentButton');
if (unblockUI) {
this.call('ui', 'unblock');
}
},

Code 2:

/**
* @override
*/
async start() {
// Synchronously initialize paymentContext before any await.
this.paymentContext = {};
Object.assign(this.paymentContext, this.el.dataset);

await this._super(...arguments);

// Expand the payment form of the selected payment option if there is only one.
const checkedRadio = document.querySelector('input[name="o_payment_radio"]:checked');
if (checkedRadio) {
await this._expandInlineForm(checkedRadio);
this._enableButton(false);
console.log("\n\n--first---")
} else {
this._setPaymentFlow(); // Initialize the payment flow to let providers overwrite it.
}

this.$('[data-bs-toggle="tooltip"]').tooltip();
},

Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 24
1451
0
jul 24
644
1
jul 24
585
2
mar 24
3327
0
sept 24
629