简体   繁体   English

如何覆盖 odoo 12 中的 _createStripeToken 函数

[英]How to override the _createStripeToken function in odoo 12

I'm looking for a way to override the _createStripeToken function of the payment_stripe_sca module in odoo 12.我正在寻找一种方法来覆盖 odoo 12 中 payment_stripe_sca 模块的 _createStripeToken 函数。

I am doing it like this but the console.log is not displayed.我是这样做的,但是没有显示 console.log。 If I add this console log in the original one it is displayed如果我在原始控制台日志中添加此控制台日志,则会显示

    PaymentForm.include({

    /**
     * @override
     * @private
     * @param {Event} ev
     * @param {DOMElement} checkedRadio
     * @param {Boolean} addPmEvent
     */
    _createStripeToken: function (ev, $checkedRadio, addPmEvent) {
        console.log("Adfadsfasdfasdfas")
    }

})

You need to patch the payment form class and add the js file to the frontend assets ( web.assets_frontend ).您需要修补支付表单类并将js文件添加到前端资产( web.assets_frontend )。

  • Override the _createStripeToken function:覆盖_createStripeToken函数:

     odoo.define('stack_overflow.payment_form', function (require) { "use strict"; var PaymentForm = require('payment.payment_form'); PaymentForm.include({ _createStripeToken: function (ev, $checkedRadio, addPmEvent) { var self = this; console.log("Adfadsfasdfasdfas"); return this._super.apply(this, arguments); }, }); });
  • Add the file to the front end assets:将文件添加到前端资产中:

     <template id="assets_frontend" inherit_id="web.assets_frontend" name="Payment Stripe SCA Assets"> <xpath expr="." position="inside"> <script type="text/javascript" src="/stack_overflow/static/src/js/payment_form.js"></script> </xpath> </template>

Check assets management for details.详情请查看资产管理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM