summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Yelizariev <iel@odoo.com>2021-01-08 15:02:19 +0000
committerIvan Yelizariev <iel@odoo.com>2021-01-08 15:02:19 +0000
commitdb0b65e547defe3d49c1a31c4671f546aa5156e8 (patch)
treed3b717f331a3546cc7b0159e224fce8377b6a279
parentc7375ebaf8d4baa6e02534425ed634c7264ce90f (diff)
[FIX] point_of_sale: respect setting only_round_cash_method
STEPS: * configure rounding: - cash_rounding=True - only_round_cash_method=True - round method: 1.0 Down * open a session * add products with subtotal in decimals (such as 6.35) * select Bank payment method and process the order BEFORE: error "You have to round your payments lines" AFTER: order is processed and marked as paid --- https://github.com/odoo/odoo/commit/42425996e36d9cb1fc1391402cf6d00df4aea019 opw-2426027 closes odoo/odoo#64270 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
-rw-r--r--addons/point_of_sale/models/pos_order.py5
-rw-r--r--addons/point_of_sale/static/src/js/models.js4
2 files changed, 8 insertions, 1 deletions
diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py
index 32a0d05a2df..a73f028aa26 100644
--- a/addons/point_of_sale/models/pos_order.py
+++ b/addons/point_of_sale/models/pos_order.py
@@ -370,7 +370,10 @@ class PosOrder(models.Model):
def action_pos_order_paid(self):
self.ensure_one()
- if not self.config_id.cash_rounding:
+ # TODO: add support for mix of cash and non-cash payments when both cash_rounding and only_round_cash_method are True
+ if not self.config_id.cash_rounding \
+ or self.config_id.only_round_cash_method \
+ and not any(p.payment_method_id.is_cash_count for p in self.payment_ids):
total = self.amount_total
else:
total = float_round(self.amount_total, precision_rounding=self.config_id.rounding_method.rounding, rounding_method=self.config_id.rounding_method.rounding_method)
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index 30e662ed18d..72a0a419c77 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -3337,10 +3337,14 @@ exports.Order = Backbone.Model.extend({
if(!this.pos.config.cash_rounding)
return false;
+ const only_cash = this.pos.config.only_round_cash_method;
var lines = this.paymentlines.models;
for(var i = 0; i < lines.length; i++) {
var line = lines[i];
+ if (only_cash && !line.payment_method.is_cash_count)
+ continue;
+
if(!utils.float_is_zero(line.amount - round_pr(line.amount, this.pos.cash_rounding[0].rounding), 6))
return line;
}