猿问

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

我想修改这个“减号按钮”,如果用户单击生成令牌,则该按钮将对该订单禁用。简单来说,为其订单生成令牌的用户无法删除其当前令牌。


江户川乱折腾
浏览 133回答 1
1回答

沧海一幻觉

我想出了一些临时修复方案,但这不是解决方案:好的,基本上我就是这么做的PosBaseWidget.include({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; init: function(parent, options) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this._super(parent, options);&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; get_order_by_uid: function(uid) {&nbsp; &nbsp; &nbsp; &nbsp; var orders = this.pos.get_order_list();&nbsp; &nbsp; &nbsp; &nbsp; for (var i = 0; i < orders.length; i++) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (orders[i].uid === uid) {//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this.pos.get_order().token_number=Token;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return orders[i];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; return undefined;&nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; deleteorder_click_handler: function(event, $el) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var self&nbsp; = this;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var order = this.pos.get_order();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!order) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else if ( !order.is_empty() ){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.gui.show_popup('confirm',{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'title': _t('Destroy Current Order ?'),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'body': _t('You will lose any data associated with the current order'),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; confirm: function(){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.pos.delete_current_order();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.pos.delete_current_order();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renderElement: function(){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var self = this;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this._super();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.$('.order-button.select-order').click(function(event){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.$('.neworder-button').click(function(event){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.neworder_click_handler(event,$(this));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.$('.deleteorder-button').click(function(event){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(Token == null )&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.deleteorder_click_handler(event,$(this));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.neworder_click_handler(event,$(this));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.pos.get_order().order_progress="In progress";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; &nbsp; &nbsp; }});where&nbsp;&nbsp; &nbsp; &nbsp;var PosBaseWidget = require('point_of_sale.BaseWidget');&nbsp; &nbsp; &nbsp;var Token = Math.floor((Math.random() * 1000) + 1000);令牌实际上在这里帮助为当前会话中的每个订单分配随机唯一编号,这只是对我的问题的临时解决方案,并且还产生了一些新问题*例如“新订单按钮[+签名按钮]一键创建两个订单”。*作为 odoo 的新手,对其 javascript 来说是陌生的(不是常规的 javascript )我每天都在开发模块来改进这一点。在找到对我的问题更持久的解决方案后将进行更新。非常感谢建议、提示、意见和建议。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答