Odoo 11添加弹出窗口SyntaxError:

时间:2019-04-15 23:01:19

标签: javascript odoo odoo-10 odoo-11

我有一个可以在Odoo 10中使用的模块。我将代码迁移到了odoo 11,但是仍然有问题。

这是我的JS文件

odoo.define('pos_custom.pos_global_discount', function(require) {
    "use strict";

    var models = require('point_of_sale.models');
    var screens = require('point_of_sale.screens');
    var gui = require('point_of_sale.gui');
    var PopupWidget = require('point_of_sale.popups');
    var utils = require('web.utils');
    var round_pr = utils.round_precision;
    var _super_order = models.Order.prototype;
    models.Order = models.Order.extend({
        initialize: function(attributes,options){
            _super_order.initialize.apply(this, arguments);

     screens.ProductScreenWidget.include({
        click_product: function(product) {
            if (this.pos.config.custom_discount_product_id &&
                this.pos.config.custom_discount_product_id[0] == product.id) {
                this.pos.gui.show_popup('add_discount_product_popup', {
                    product: product,
                    product_options: {}
                });
            } else {
                this._super.apply(this, arguments);
            }
        },
    });




    var AddDiscountProductPopup = PopupWidget.extend({
        template: 'AddDiscountProductPopup',
        show: function(options){
            options = options || {}
            this.product = options.product
            this.product_options = options.product_options
            this._super(options);
            this.$('.discount_product').focus();
            this.$('.discount_product').on("keypress keyup blur",function (event) {
               //this.value = this.value.replace(/[^0-9\.]/g,'');
                $(this).val($(this).val().replace(/[^0-9\.]/g,''));
                if ((event.which != 46 || $(this).val().indexOf('.') != -1) &&
                (event.which < 48 || event.which > 57)) {
                    event.preventDefault();
                }
            });
        },


        click_confirm: function(){
            var order = this.pos.get_order();
            var $value = this.$('.discount_product').val();
            $value = $.isNumeric($value) ? parseFloat($value) : 0.00;
            this.product_options['price'] = -$value;
            this.product_options['hide_popup'] = true;
            order.add_product(this.product, this.product_options);
            this.gui.close_popup();
        },
    });
    gui.define_popup({name:'add_discount_product_popup', widget: AddDiscountProductPopup});
});

我在属性列表后收到了SyntaxError:missing}。注意:{在第1701行第388列打开

我认为这与下面有关,但我只是在猜测。 ..

models.Order = models.Order.extend({
        initialize: function(attributes,options){
            _super_order.initialize.apply(this, arguments);

2 个答案:

答案 0 :(得分:0)

尝试在右花括号后除去逗号。逗号表示该系列中还有其他内容,即使这是该系列的结尾,在两个地方都可以找到它。

},更改为}

答案 1 :(得分:0)

用下面的代码替换那三行。

models.Order = models.Order.extend({
            initialize: function(attributes,options){
                _super_order.initialize.apply(this, arguments);


                 after this lines put below brackets.

               },
    });
相关问题