简体   繁体   English

Odoo扩展website_sale JS功能

[英]Odoo extend website_sale JS function

Hello I'd like to inherit on the following function $shippingDifferent.change(function (event) { under website_sale.js in order to add the following piece of code in it: 您好,我想在website_sale.js下的以下函数$ shippingDifferent.change(function(event){上继承 ,以便在其中添加以下代码:

if (value == 1) {
        value = 0   
}

I know how to include or extend a Module but here there is no module, so any ideas? 我知道如何包括或扩展模块,但是这里没有模块,所以有什么想法吗?

First of all i would suggest you one line: 首先,我建议您一行:

Never ever use the website_sale.js for the purpose of reference. 绝对不要将website_sale.js用作参考。

As it's contain raw j query instead of backbone.js . 因为它包含原始j查询,而不是bone.js。

You can't use the concept of include and extend Like: 您不能使用includeextend这样的概念:

var website_sale = require('website_sale.website_sale');
   website_sale.include({
     include_my_task: function() {
        var self = this;
         // body of  logic to be included ...

        },
    });

   website_sale.extend({
     override_prev_task: function() {
       var self = this;
       this._super();
       // body of  logic to be extended ...

     },
   });

Below i am posting some j query based code snippet, it's may help you. 我在下面发布了一些基于j查询的代码段,可能会对您有所帮助。

   $(document).ready(function() 
 {   
      odoo.define("website_sale.website_sale", function (require) 
      {
            "use strict";
            $(".oe_website_sale").each(function () {
             var oe_website_sale = this;
                function do_my_task (event) {
                        // body...
                }

                $(oe_website_sale).on("click", "span.my_class",do_my_task );

           });
      }
});

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

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