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
Advertisement
Answer
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 )
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.