From a1ed181c6d5630d079d9b8debafca6a05dc55eb2 Mon Sep 17 00:00:00 2001 From: Frederic van der Essen Date: Mon, 25 Aug 2014 15:36:30 +0200 Subject: [PATCH] [IMP] point_of_sale: The invoice button in the payment screen now sets the order to be invoiced instead of directly invoicing the order --- addons/point_of_sale/static/src/css/pos.css | 9 +++---- addons/point_of_sale/static/src/js/models.js | 7 ++++++ addons/point_of_sale/static/src/js/screens.js | 24 +++++++++++++++---- addons/point_of_sale/static/src/xml/pos.xml | 2 +- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index e1e9a1c45f8..1609e1b2633 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -496,10 +496,11 @@ td { margin-right: 4px; } -.pos .control-button.highlight{ - background: #6EC89B; - border: solid 1px #6EC89B; - color: white; +.pos .control-button.highlight, +.pos .button.highlight { + background: #6EC89B !important; + border: solid 1px #6EC89B !important; + color: white !important; } .pos .control-button:active { background: #7F82AC; diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 02a84c61b51..e57353fd231 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -864,6 +864,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal this.receipt_type = 'receipt'; // 'receipt' || 'invoice' this.temporary = attributes.temporary || false; this.sequence_number = this.pos.pos_session.sequence_number++; + this.to_invoice = false; return this; }, is_empty: function(){ @@ -1068,6 +1069,12 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal } } }, + set_to_invoice: function(to_invoice) { + this.to_invoice = to_invoice; + }, + is_to_invoice: function(){ + return this.to_invoice; + }, // remove all the paymentlines with zero money in it clean_empty_paymentlines: function() { var lines = this.get('paymentLines').models; diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index d4a20d1aef1..4cf53f2fac3 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -1024,6 +1024,15 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }); return methods; }, + click_invoice: function(){ + var order = this.pos.get_order(); + order.set_to_invoice(!order.is_to_invoice()); + if (order.is_to_invoice()) { + this.$('.js_invoice').addClass('highlight'); + } else { + this.$('.js_invoice').removeClass('highlight'); + } + }, renderElement: function() { var self = this; this._super(); @@ -1045,7 +1054,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }); this.$('.js_invoice').click(function(){ - self.validate_order({invoice: true}); + self.click_invoice(); }); }, @@ -1086,9 +1095,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }, // Check if the order is paid, then sends it to the backend, // and complete the sale process - validate_order: function(options) { + validate_order: function() { var self = this; - options = options || {}; var order = this.pos.get_order(); @@ -1100,14 +1108,20 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.pos.proxy.open_cashbox(); } - if (options.invoice) { + if (order.is_to_invoice()) { var invoiced = this.pos.push_and_invoice_order(order); this.invoicing = true; invoiced.fail(function(error){ self.invoicing = false; if (error === 'error-no-client') { - self.pos_widget.screen_selector.set_current_screen('clientlist'); + self.pos_widget.screen_selector.show_popup('confirm',{ + message: _t('Please select the Customer'), + comment: _t('You need to select the customer before you can invoice an order.'), + confirm: function(){ + self.pos_widget.screen_selector.set_current_screen('clientlist'); + }, + }); } else { self.pos_widget.screen_selector.show_popup('error-invoice-transfer'); } diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 284ac787611..e2fdc392a40 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -528,7 +528,7 @@
-
+
Invoice