使用JavaScript修改POS odoo中的删除顺序功能

问题描述

我想以某种方式修改“减号按钮”,如果用户单击“生成令牌”,则该按钮将对该订单禁用 简而言之,为其订单生成令牌的用户无法删除其当前令牌。UI of POS with added widget

解决方法

我想出了一些临时解决方案,但不是解决方案:

好吧,我基本上是这样做的

PosBaseWidget.include({

          init: function(parent,options) {
            this._super(parent,options);

        },get_order_by_uid: function(uid) {
        var orders = this.pos.get_order_list();
        for (var i = 0; i < orders.length; i++) {
            if (orders[i].uid === uid) {
//                 this.pos.get_order().token_number=Token;
                return orders[i];
            }
        }
        return undefined;
    },deleteorder_click_handler: function(event,$el) {
            var self  = this;
            var order = this.pos.get_order();

            if (!order) {
                return;
            } else if ( !order.is_empty() ){

                this.gui.show_popup('confirm',{
                    'title': _t('Destroy Current Order ?'),'body': _t('You will lose any data associated with the current order'),confirm: function(){
                        self.pos.delete_current_order();
                    },});
            } else {
                this.pos.delete_current_order();
            }
        },renderElement: function(){
            var self = this;
            this._super();
            this.$('.order-button.select-order').click(function(event){

            });
            this.$('.neworder-button').click(function(event){
                self.neworder_click_handler(event,$(this));
            });
            this.$('.deleteorder-button').click(function(event){
                if(Token == null )
               {
                    self.deleteorder_click_handler(event,$(this));

               }
                else
                {
                    self.neworder_click_handler(event,$(this));
                      this.pos.get_order().order_progress="In progress";

                }
            });

        }

});

where 
     var PosBaseWidget = require('point_of_sale.BaseWidget');
     var Token = Math.floor((Math.random() * 1000) + 1000);

令牌实际上在这里帮助在当前会话中为每个订单分配随机唯一编号 它只是对我的问题的临时修复,并且还会出现一些新问题,例如“新订单按钮[+签名按钮]一键创建两个订单”。 *

对于odoo来说是新事物,对javascript(不是常规javascript)是陌生的

我每天都在研究该模块以改进此问题。将更新 在找到对我的问题的更持久的解决方法之后。建议,提示,意见和 建议非常受赞赏。