[FIX] point_of_sale: prevent inexact payements when there is no cash payment method...
authorFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>
Mon, 8 Sep 2014 10:49:34 +0000 (12:49 +0200)
committerFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>
Mon, 8 Sep 2014 16:06:51 +0000 (18:06 +0200)
addons/point_of_sale/static/src/js/screens.js

index a543cb8..9e66f34 100644 (file)
@@ -1067,6 +1067,21 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
                 return;
             }
 
+            // The exact amount must be paid if there is no cash payment method defined.
+            if (Math.abs(currentOrder.getTotalTaxIncluded() - currentOrder.getPaidTotal()) > 0.00001) {
+                var cash = false;
+                for (var i = 0; i < this.pos.cashregisters.length; i++) {
+                    cash = cash || (this.pos.cashregisters[i].journal.type === 'cash');
+                }
+                if (!cash) {
+                    this.pos_widget.screen_selector.show_popup('error',{
+                        message: _t('Cannot return change without a cash payment method'),
+                        comment: _t('There is no cash payment method available in this point of sale to handle the change.\n\n Please pay the exact amount or add a cash payment method in the point of sale configuration'),
+                    });
+                    return;
+                }
+            }
+
             if(    this.pos.config.iface_cashdrawer 
                 && this.pos.get('selectedOrder').get('paymentLines').find( function(pl){ 
                            return pl.cashregister.journal.type === 'cash';