[WIP] point_of_sale: refactor error popups in preparation of a multicompany-screwup prevention error popup
This commit is contained in:
parent
7be175bad6
commit
dc8e18ac04
|
@ -314,58 +314,28 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
module.ChooseReceiptPopupWidget = module.PopUpWidget.extend({
|
||||
template:'ChooseReceiptPopupWidget',
|
||||
show: function(){
|
||||
this._super();
|
||||
this.renderElement();
|
||||
var self = this;
|
||||
var currentOrder = self.pos.get('selectedOrder');
|
||||
|
||||
this.$('.button.receipt').off('click').click(function(){
|
||||
currentOrder.set_receipt_type('receipt');
|
||||
self.pos_widget.screen_selector.set_current_screen('products');
|
||||
});
|
||||
|
||||
this.$('.button.invoice').off('click').click(function(){
|
||||
currentOrder.set_receipt_type('invoice');
|
||||
self.pos_widget.screen_selector.set_current_screen('products');
|
||||
});
|
||||
},
|
||||
get_client_name: function(){
|
||||
var client = this.pos.get('selectedOrder').get_client();
|
||||
if( client ){
|
||||
return client.name;
|
||||
}else{
|
||||
return '';
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
module.ErrorPopupWidget = module.PopUpWidget.extend({
|
||||
template:'ErrorPopupWidget',
|
||||
show: function(text){
|
||||
show: function(options){
|
||||
options = options || {};
|
||||
var self = this;
|
||||
this._super();
|
||||
|
||||
$('body').append('<audio src="/point_of_sale/static/src/sounds/error.wav" autoplay="true"></audio>');
|
||||
|
||||
if( text ) {
|
||||
if ( text.message || text.comment ) {
|
||||
this.$('.message').text(text.message);
|
||||
this.$('.comment').text(text.comment);
|
||||
} else {
|
||||
this.$('.message').text(_t('Error'));
|
||||
this.$('.comment').html(text);
|
||||
}
|
||||
}
|
||||
this.message = options.message || _t('Error');
|
||||
this.comment = options.comment || '';
|
||||
|
||||
this.renderElement();
|
||||
|
||||
this.pos.barcode_reader.save_callbacks();
|
||||
this.pos.barcode_reader.reset_action_callbacks();
|
||||
this.$('.footer .button').off('click').click(function(){
|
||||
|
||||
this.$('.footer .button').click(function(){
|
||||
self.pos_widget.screen_selector.close_popup();
|
||||
});
|
||||
if ( options.confirm ) {
|
||||
options.confirm.call(self);
|
||||
}
|
||||
},
|
||||
close:function(){
|
||||
this._super();
|
||||
|
@ -377,16 +347,11 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
template:'ErrorTracebackPopupWidget',
|
||||
});
|
||||
|
||||
module.ErrorSessionPopupWidget = module.ErrorPopupWidget.extend({
|
||||
template:'ErrorSessionPopupWidget',
|
||||
});
|
||||
|
||||
module.ErrorBarcodePopupWidget = module.ErrorPopupWidget.extend({
|
||||
template:'ErrorBarcodePopupWidget',
|
||||
show: function(barcode){
|
||||
this.barcode = barcode;
|
||||
this._super();
|
||||
this.$('.barcode').text(barcode);
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -1117,9 +1082,15 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
|
||||
invoiced.fail(function(error){
|
||||
if(error === 'error-no-client'){
|
||||
self.pos_widget.screen_selector.show_popup('error-no-client');
|
||||
self.pos_widget.screen_selector.show_popup('error',{
|
||||
message: _t('An anonymous order cannot be invoiced'),
|
||||
comment: _t('Please select a client for this order. This can be done by clicking the order tab'),
|
||||
});
|
||||
}else{
|
||||
self.pos_widget.screen_selector.show_popup('error-invoice-transfer');
|
||||
self.pos_widget.screen_selector.show_popup('error',{
|
||||
message: _t('The order could not be sent'),
|
||||
comment: _t('Check your internet connection and try again.'),
|
||||
});
|
||||
}
|
||||
self.pos_widget.action_bar.set_button_disabled('validation',false);
|
||||
self.pos_widget.action_bar.set_button_disabled('invoice',false);
|
||||
|
|
|
@ -1113,15 +1113,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
this.error_barcode_popup = new module.ErrorBarcodePopupWidget(this, {});
|
||||
this.error_barcode_popup.appendTo(this.$el);
|
||||
|
||||
this.error_session_popup = new module.ErrorSessionPopupWidget(this, {});
|
||||
this.error_session_popup.appendTo(this.$el);
|
||||
|
||||
this.choose_receipt_popup = new module.ChooseReceiptPopupWidget(this, {});
|
||||
this.choose_receipt_popup.appendTo(this.$el);
|
||||
|
||||
this.error_no_client_popup = new module.ErrorNoClientPopupWidget(this, {});
|
||||
this.error_no_client_popup.appendTo(this.$el);
|
||||
|
||||
this.error_invoice_transfer_popup = new module.ErrorInvoiceTransferPopupWidget(this, {});
|
||||
this.error_invoice_transfer_popup.appendTo(this.$el);
|
||||
|
||||
|
@ -1198,10 +1192,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
popup_set:{
|
||||
'error': this.error_popup,
|
||||
'error-barcode': this.error_barcode_popup,
|
||||
'error-session': this.error_session_popup,
|
||||
'choose-receipt': this.choose_receipt_popup,
|
||||
'error-no-client': this.error_no_client_popup,
|
||||
'error-invoice-transfer': this.error_invoice_transfer_popup,
|
||||
'error-traceback': this.error_traceback_popup,
|
||||
'confirm': this.confirm_popup,
|
||||
'unsent-orders': this.unsent_orders_popup,
|
||||
|
|
|
@ -574,55 +574,6 @@
|
|||
</receipt>
|
||||
</t>
|
||||
|
||||
<t t-name="ChooseReceiptPopupWidget">
|
||||
<div class="modal-dialog">
|
||||
<div class="popup popup-receipt">
|
||||
<p class="message">Welcome <t t-esc="widget.get_client_name()" /><br /> Choose your type of receipt:</p>
|
||||
<div class = "button big-left receipt">
|
||||
Ticket
|
||||
</div>
|
||||
<div class = "button big-right invoice">
|
||||
Invoice
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="ErrorSessionPopupWidget">
|
||||
<div class="modal-dialog">
|
||||
<div class="popup popup-nosession">
|
||||
<p class="message">Sorry, we could not create a session for this user.</p>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="ErrorNoClientPopupWidget">
|
||||
<div class="modal-dialog">
|
||||
<div class="popup popup-noclient">
|
||||
<p class="message">An anonymous order cannot be invoiced</p>
|
||||
<div class="footer">
|
||||
<div class="button">
|
||||
Ok
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="ErrorInvoiceTransferPopupWidget">
|
||||
<div class="modal-dialog">
|
||||
<div class="popup popup-invoice">
|
||||
<p class="message">The Order could not be sent to the server for invoicing. Invoices cannot be generated
|
||||
in offline mode. Please check your internet connection and try again.</p>
|
||||
<div class="footer">
|
||||
<div class="button">
|
||||
Ok
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="ErrorPopupWidget">
|
||||
<div class="modal-dialog">
|
||||
<div class="popup popup-error">
|
||||
|
@ -656,7 +607,7 @@
|
|||
<div class="popup popup-barcode">
|
||||
<p class="message">Unknown Barcode
|
||||
<br />
|
||||
<span class='barcode'></span>
|
||||
<span class='barcode'><t t-esc="widget.barcode" /></span>
|
||||
</p>
|
||||
<p class="comment">
|
||||
The Point of Sale could not find any product, client, employee
|
||||
|
|
Loading…
Reference in New Issue