[IMP] point_of_sale: The invoice button in the payment screen now sets the order...
authorFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>
Mon, 25 Aug 2014 13:36:30 +0000 (15:36 +0200)
committerFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>
Mon, 25 Aug 2014 13:36:30 +0000 (15:36 +0200)
addons/point_of_sale/static/src/css/pos.css
addons/point_of_sale/static/src/js/models.js
addons/point_of_sale/static/src/js/screens.js
addons/point_of_sale/static/src/xml/pos.xml

index e1e9a1c..1609e1b 100644 (file)
@@ -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;
index 02a84c6..e57353f 100644 (file)
@@ -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;
index d4a20d1..4cf53f2 100644 (file)
@@ -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');
                     }
index 284ac78..e2fdc39 100644 (file)
 
                     <div class='payment-buttons'>
                         <t t-if='widget.pos.config.iface_invoicing'>
-                            <div class='button js_invoice'>
+                            <div t-attf-class='button js_invoice #{ widget.pos.get_order().is_to_invoice() ? "highlight" : ""} '>
                                 <i class='fa fa-file-text-o' /> Invoice
                             </div>
                         </t>