From 302d8a526441b85120f1b4501bae3efcbe700d47 Mon Sep 17 00:00:00 2001 From: Joren Van Onder <jov@odoo.com> Date: Fri, 2 Feb 2018 01:34:53 +0000 Subject: [PATCH] [FIX] point_of_sale: allow refunds on non-cash journals Cherry pick of 5b769650d6416be123e972aa8f4b2b2c25ce438f in version 11.0 A customer can pay an order with a non-cash journal (e.g. a credit card through a stand-alone terminal). When this order has to be refunded later it should be possible to do so on that same journal. Some code prevented this from happening, notably a check in order_is_valid which explicitly prevented this for an unknown reason. There is no explanation in the commit (4647f896a428a19daa5b0bc3585e801110e815b4) introducing that. This commit allows the following: 1. input what you want to refund with a negative qty 2. click 'Payment' 3. click the Credit Card (type Bank) journal 4. (amount is auto-populated) 5. click 'Validate' opw-805302 opw-1913731 closes odoo/odoo#30218 --- addons/point_of_sale/static/src/js/models.js | 6 +++--- addons/point_of_sale/static/src/js/screens.js | 11 ----------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index dd2eb8d9596f..fa6215ee0e87 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -2092,7 +2092,7 @@ exports.Order = Backbone.Model.extend({ this.assert_editable(); var newPaymentline = new exports.Paymentline({},{order: this, cashregister:cashregister, pos: this.pos}); if(cashregister.journal.type !== 'cash' || this.pos.config.iface_precompute_cash){ - newPaymentline.set_amount( Math.max(this.get_due(),0) ); + newPaymentline.set_amount( this.get_due() ); } this.paymentlines.add(newPaymentline); this.select_paymentline(newPaymentline); @@ -2256,10 +2256,10 @@ exports.Order = Backbone.Model.extend({ } } } - return round_pr(Math.max(0,due), this.pos.currency.rounding); + return round_pr(due, this.pos.currency.rounding); }, is_paid: function(){ - return this.get_due() === 0; + return this.get_due() <= 0; }, is_paid_with_cash: function(){ return !!this.paymentlines.find( function(pl){ diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 7c1cb9559a6d..82e6fa0e7b25 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -1943,17 +1943,6 @@ var PaymentScreenWidget = ScreenWidget.extend({ return false; } - var plines = order.get_paymentlines(); - for (var i = 0; i < plines.length; i++) { - if (plines[i].get_type() === 'bank' && plines[i].get_amount() < 0) { - this.gui.show_popup('error',{ - 'message': _t('Negative Bank Payment'), - 'comment': _t('You cannot have a negative amount in a Bank payment. Use a cash payment method to return money to the customer.'), - }); - return false; - } - } - if (!order.is_paid() || this.invoicing) { return false; } -- GitLab