From 85d697670c452b262baff2069ece9083ee60d243 Mon Sep 17 00:00:00 2001 From: Frederic van der Essen Date: Tue, 22 Jul 2014 14:33:32 +0200 Subject: [PATCH] [IMP] point_of_sale: show traceback popup when there is a server error when posting orders (which should NEVER happen !) --- addons/point_of_sale/point_of_sale.py | 1 + addons/point_of_sale/static/src/css/pos.css | 7 +++++++ addons/point_of_sale/static/src/js/models.js | 8 +++++++- addons/point_of_sale/static/src/js/screens.js | 3 +++ addons/point_of_sale/static/src/js/widgets.js | 4 ++++ addons/point_of_sale/static/src/xml/pos.xml | 14 ++++++++++++++ 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 805ce104221..46e4438a12a 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -553,6 +553,7 @@ class pos_order(osv.osv): orders_to_save = [o for o in orders if o['data']['name'] not in existing_references] order_ids = [] + for tmp_order in orders_to_save: to_invoice = tmp_order['to_invoice'] order = tmp_order['data'] diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 30939636b23..9836e5d9280 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -1665,6 +1665,13 @@ td { font-size: 18px; margin: 0px 16px; } +.pos .popup .comment.traceback { + height: 264px; + overflow: auto; + font-size: 14px; + text-align: left; + font-family: 'Inconsolata'; +} .pos .popup .footer{ position:absolute; bottom:0; diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 17278ed1bd9..222d5663621 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -451,7 +451,13 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal self.db.remove_order(order.id); }); return server_ids; - }).fail(function (unused, event){ + }).fail(function (error, event){ + if(error.code === 200 ){ // Business Logic Error, not a connection problem + self.pos_widget.screen_selector.show_popup('error-traceback',{ + message: error.data.message, + comment: error.data.debug + }); + } // prevent an error popup creation by the rpc failure // we want the failure to be silent as we send the orders in the background event.preventDefault(); diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index e2db20decc5..ca09719a2f0 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -367,6 +367,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }, }); + module.ErrorTracebackPopupWidget = module.ErrorPopupWidget.extend({ + template:'ErrorTracebackPopupWidget', + }); module.ErrorSessionPopupWidget = module.ErrorPopupWidget.extend({ template:'ErrorSessionPopupWidget', diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 66130a7740c..cc9a8fe9e3a 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -1082,6 +1082,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.error_invoice_transfer_popup = new module.ErrorInvoiceTransferPopupWidget(this, {}); this.error_invoice_transfer_popup.appendTo(this.$el); + this.error_traceback_popup = new module.ErrorTracebackPopupWidget(this,{}); + this.error_traceback_popup.appendTo(this.$el); + this.confirm_popup = new module.ConfirmPopupWidget(this,{}); this.confirm_popup.appendTo(this.$el); @@ -1139,6 +1142,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa '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, }, default_screen: 'products', diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 929212cce8d..93f008ffab2 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -635,6 +635,20 @@ + + + +