Odoo 11 добавить всплывающее окно SyntaxError: - PullRequest
0 голосов
/ 16 апреля 2019

У меня есть модуль, который работает в 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 голосов
/ 16 апреля 2019

Замените эти 3 строки следующим кодом.

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


                 after this lines put below brackets.

               },
    });
0 голосов
/ 16 апреля 2019

Попробуйте удалить запятую после правой фигурной скобки.Запятая означает, что в серии есть что-то еще, и у вас есть два места, даже если это конец серии.

Измените }, на }

...