Odoo 11添加弹出语法SyntaxError:

问题描述 投票:0回答:2

我有一个在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);
javascript odoo odoo-10 odoo-11
2个回答
0
投票

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

},改为}


0
投票

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

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


                 after this lines put below brackets.

               },
    });
© www.soinside.com 2019 - 2024. All rights reserved.