[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
This commit is contained in:
committed by
Nicolas Martinelli
parent
1748fa2aa0
commit
6470ee74b8
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user