summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2018-08-07 10:36:26 +0200
committerNicolas Martinelli <nim-odoo@users.noreply.github.com>2018-08-07 17:33:57 +0200
commit6470ee74b8cae9c62a47118850533e9a8e8301ac (patch)
tree3523e983db6588b0a6b7c7110c79d5589328ec11 /addons
parent1748fa2aa0031b0cf01dee8d3dd516f86b7295f1 (diff)
[FIX] point_of_sale: return with rounding < 0.01
- Set the currency to a rounding of 0.001 - Create a POS order: Unit Price: 0.12 Quantity: 0.1 - Pay and validate - From the backend, return the products on the create order - Click on 'Payment' The proposed amount is 0.01, not 0.012. It is not possible to complete the payment process since the field is rounded at DB level to 2 digits of precision. We make consistent the `amount` field with the various amounts on the `pos.order`. By using a `digits=0` and forcing the rounding, we avoid inconsistent rounding between the order and the payment. opw-1864344
Diffstat (limited to 'addons')
-rw-r--r--addons/point_of_sale/wizard/pos_payment.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py
index e4b494badde..a2578ffef9c 100644
--- a/addons/point_of_sale/wizard/pos_payment.py
+++ b/addons/point_of_sale/wizard/pos_payment.py
@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
+from odoo.tools import float_is_zero
class PosMakePayment(models.TransientModel):
@@ -30,7 +31,7 @@ class PosMakePayment(models.TransientModel):
session_id = fields.Many2one('pos.session', required=True, default=_default_session)
journal_id = fields.Many2one('account.journal', string='Payment Mode', required=True, default=_default_journal)
- amount = fields.Float(digits=(16, 2), required=True, default=_default_amount)
+ amount = fields.Float(digits=0, required=True, default=_default_amount)
payment_name = fields.Char(string='Payment Reference')
payment_date = fields.Date(string='Payment Date', required=True, default=lambda *a: fields.Datetime.now())
@@ -49,11 +50,13 @@ class PosMakePayment(models.TransientModel):
"""
self.ensure_one()
order = self.env['pos.order'].browse(self.env.context.get('active_id', False))
+ currency = order.pricelist_id.currency_id
amount = order.amount_total - order.amount_paid
data = self.read()[0]
# add_payment expect a journal key
data['journal'] = data['journal_id'][0]
- if amount != 0.0:
+ data['amount'] = currency.round(data['amount']) if currency else data['amount']
+ if not float_is_zero(amount, precision_rounding=currency.rounding or 0.01):
order.add_payment(data)
if order.test_paid():
order.action_pos_order_paid()