使用 javascript 修改 POS odoo 中的删除订单功能
Modifying delete order function in POS odoo using javascript
我想修改这个“减号按钮”,如果用户点击生成令牌,该按钮将对该订单禁用
简而言之,为 his/her 订单生成令牌的用户无法删除其当前令牌。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);
token 实际上在这里帮助为当前会话中的每个订单分配随机唯一编号
它只是对我的问题的临时修复,它还会出现一些新问题 *比如“新订单按钮 [+ 签名按钮] 一次点击创建两个订单”。 *
作为 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.
我想修改这个“减号按钮”,如果用户点击生成令牌,该按钮将对该订单禁用 简而言之,为 his/her 订单生成令牌的用户无法删除其当前令牌。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);
token 实际上在这里帮助为当前会话中的每个订单分配随机唯一编号 它只是对我的问题的临时修复,它还会出现一些新问题 *比如“新订单按钮 [+ 签名按钮] 一次点击创建两个订单”。 *
作为 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.