简体   繁体   English

使用javascript修改POS odoo中的删除订单功能

[英]Modifying delete order function in POS odoo using javascript

I want to modify this " minus button " in such a way that if the user click on generate token this button become disabled for that order In simple words, the user who generated a token for his/her order cannot delete their current token.我想修改这个“减号按钮”,如果用户点击生成令牌,该按钮将被禁用该订单简而言之,为他/她的订单生成令牌的用户不能删除他们当前的令牌。 UI of POS with added widget添加小部件的 POS 用户界面

i came up with some temporary fixes, but its not the solution:我想出了一些临时修复,但这不是解决方案:

Ok basically i did this好的,基本上我是这样做的

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);

token is actually helping here to assign random unique number to each order in current session It just a temporary fix to my issue and its also arises some new issues *like " new order button [+ signed button] creates two orders on one click".令牌实际上在这里帮助为当前会话中的每个订单分配随机唯一编号这只是对我的问题的临时解决方案,它还出现了一些新问题*例如“新订单按钮[+签名按钮]单击即可创建两个订单”。 * *

As new to odoo and alien to its javascript( not regular javascript )作为 odoo 的新手和其 javascript 的外星人(不是常规的 javascript)

i am working on the module to improve this everyday.我正在研究模块以每天改进这一点。 Will be updating after finding more durable fix to my question.Advice,Tips,Opinions and suggestions are highly appreciated.在为我的问题找到更持久的解决方案后将进行更新。非常感谢建议、提示、意见和建议。

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

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